我有两个框架,使用JavaScript将第一个框架(myframe)的内容复制到第二个框架(myframe2),并设置myframe2的src:
<iframe id="myframe" src="../Page1.aspx" width="100%" height="100px"></iframe>
<iframe id="myframe2" width="100%" height="100px"></iframe>
<button onclick="myFunction();return false;">Try it</button>
<script>
function myFunction() {
var iframe1 = document.getElementById("myframe");
var iframe2 = document.getElementById("myframe2");
iframe2.contentWindow.document.body.parentElement.innerHTML = iframe1.contentWindow.document.body.parentElement.innerHTML;
iframe2.setAttribute("src", iframe1.src);
}
</script>
FrameSecond 在“src”属性设置后重新加载,但我不需要它这样做。有人可以帮我解决吗?