[英]First opportunity for document.body.appendChild
I am looking for the first opportunity to call document.body.appendChild
to attach an element. 我正在寻找第一个机会来调用
document.body.appendChild
来附加元素。 I am currently using onload
of body but as I understand it this waits until images and subframes load before triggering. 我目前正在使用body的
onload
,但据我所知,它会等到图像和子帧加载后才触发。
I require only that the solution work in IE (this is for an IE specific demo), but believe in the importance of giving cross-browser answers for other people to reference, so points if you give both. 我只要求解决方案可以在IE中工作(这是针对IE特定的演示),但是我相信提供跨浏览器答案以供其他人参考的重要性,因此,如果两者都给出,则很重要。
Below is an illustration of what I am already doing. 下面是我已经在做什么的说明。
<html>
<head>
<title>Insertion</title>
<script type="text/javascript">
function insertStuff() {
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
}
</script>
</head>
<body onload="insertStuff()">
</body>
</html>
<html>
<head>
<title>Insertion</title>
</head>
<body>
<script type="text/javascript">
function insertStuff() {
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
}
insertStuff()
</script>
<!-- Here goes all the other elements -->
</body>
</html>
This would be cross browser and work for IE6 and above for sure. 这将是跨浏览器,并且肯定适用于IE6及更高版本。 Not sure about anything below that
不知道下面什么
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.