1,点击index.html中的按钮 在frqme_a.htm文档中ID=BOX1后面添加一个DIV标签,ID=BOX1前面添加一个DIV标签
2,如何获取当前窗口中id=frame_a 框架中的所有文档3,问题还有很多!先解决这两个
index.html<html>
<herd>
<script type="text/javascript">
<!--
function to_f_a() {
这里怎么写
}
//-->
</script>
</herd><body><frame src="frame_a.htm" id="frame_a"><input type="button" value="添加DIV" onclick="to_f_a()" /></body>
</html>frame_a.htm<html>
<body><div id="box1"></div></body>
</html>
2,如何获取当前窗口中id=frame_a 框架中的所有文档3,问题还有很多!先解决这两个
index.html<html>
<herd>
<script type="text/javascript">
<!--
function to_f_a() {
这里怎么写
}
//-->
</script>
</herd><body><frame src="frame_a.htm" id="frame_a"><input type="button" value="添加DIV" onclick="to_f_a()" /></body>
</html>frame_a.htm<html>
<body><div id="box1"></div></body>
</html>
<html>
<head>
<script type="text/javascript">
<!--
function to_f_a() {
var doc = document.getElementById("frame_a").contentWindow.document;
var div = doc.createElement("div");
div.innerHTML = "inner";
var box = doc.getElementById("box1");
box.appendChild(div);
var div1 = doc.createElement("div");
div1.innerHTML = "outer";
box.parentNode.insertBefore(div1,box);
}
//-->
</script>
</head> <body>
<iframe src="frame_a.htm" id="frame_a"></iframe>
<input type="button" value="添加DIV" onclick="to_f_a()" />
</body>
</html>
document.getElementById("frame_a").contentWindow.document.body.innerHTML
窗体内建了DIV 我想保存当前窗体内所有内容保存包括<html></html>
if(document.all) alert(document.getElementById("frame_a").contentWindow.document.body.parentNode.outerHTML)
else alert("<html>" + document.getElementById("frame_a").contentWindow.document.body.parentNode.innerHTML + "</html>")