我试图在我创建的iframe的 $('body').append('<iframe src="/test-iframe.html" id="if"></iframe>');
$('#if').ready(function(){
$('head', window.frames['if'].document).append('<scr'+'ipt src=/script.js></scr'+'ipt>');
});
标记中附加html,但不是附加到我的iframe头上,而是将我的代码附加到我实际页面的负责人。我不知道为什么会发生这种情况!
以下是我尝试的内容:
$('body').append('<iframe src="/test-iframe.html" id="if"></iframe>');
$('#if').ready(function(){
$('#if').contents().find('head').append('<scr'+'ipt src=/script.js></scr'+'ipt>');
});
我也试过这个:
<html>
<head>
<script src="/script.js"></script>
</head>
<body>
<iframe src="/iframe-test.html">
<html><head></head><body>test page</body></html> <!-- This is the source of the iFrame after it loaded, obviously -->
</iframe>
</body>
</html>
但在这两种情况下,结果看起来都像是:
<head>
您可能已经看到它确实将我的脚本标记附加到了错误的<head>
标记。
如何才能将其添加到我的iFrame中的node.chef_environment
标记中?