繁体   English   中英

JS:iframe2如何更改iframe1的src?

[英]JS : How can iframe2 change the src of iframe1?

这是我的HTML来源:

<body>
<iframe id='iframe1' src="http://site1.com/myScript.html"></iframe>
<iframe id='iframe2' src="http://site2.com"></iframe>
</body>

如何(在myScript.html页面中)更改iframe的src? (或导航至site3.com)

myScript.html;

<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>

<body>
<script>
function navigateIFrame2() {
// code to change the url or navigate iframe2
}
</script>

</body>
</html>
$('#iframe2', window.parent.document).attr("src" "new url");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM