簡體   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