document.getElementById('iframe').onload=function(){
var iframe=$(document.getElementById("iframe").contentWindow.document);
$(iframe).find("head").append($("<script type='text/javascript' src='js/move.js'></script>"));//这样写没反正能得到object ,但给他append就没反应了
//$(iframe).body.html("sdfsdfds") 这样写也没问题可以修改到,$(iframe).find("head").append却没有效
}
这样,不用jquery:
document.getElementsByTagName('head')[0].innerHTML=document.getElementsByTagName('head')[0].innerHTML+"js脚本";
有人这么解释
All of jQuery's insertion methods use a domManip function internally to clean/process elements before and after they are inserted into the DOM. One of the things the domManip function does is pull out any script elements about to be inserted and run them through an "evalScript routine" rather than inject them with the rest of the DOM fragment. It inserts the scripts separately, evaluates them, and then removes them from the DOM.
说是插不进,可以执行一次,但是最后会被移除
可以了,谢谢哈
你把js拿到body下面执行试一试
.append($("<script type='text/javascript' src='js/move.js'></script>"));要写成
.append("<script type='text/javascript' src='js/move.js'></script>");
不谢!
没用呢