通过单击按钮在IFRAME地址之间切换。
<iframe src="www.example.com"></iframe>
<div id="2">
<iframe src="www.wow.com"></iframe>
答案 0 :(得分:1)
请参阅此处(运行代码):https://www.w3schools.com/code/tryit.asp?filename=FT3NWLA87A5A
function func(){
var url1 = document.getElementById("frame1").src;
var url2 = document.getElementById("frame2").src;
document.getElementById("frame1").src=url2;
document.getElementById("frame2").src=url1;
}
<iframe src="https://www.w3schools.com" id="frame1">
<p>Your browser does not support iframes.</p>
</iframe>
<iframe src="https://www.findertoday.com" id="frame2">
<p>Your browser does not support iframes.</p>
</iframe>
<button onclick="func()">Switch</button>