html实现iframe内嵌页面跳转的demo

记录一下iframe内嵌页面的跳转方式

代码:

index.html:

<html> <head> <title>根目录</title> <script> function changeSrc1() { document.getElementById("iframe1").setAttribute("src","1.html"); } function changeSrc2() { document.getElementById("iframe1").setAttribute("src","2.html"); } </script> </head> <body> <div> <button id="btn-sub1" href="1.html" target="iframe1" onclick="changeSrc1()">切换到页面一</button> <button id="btn-sub2" href="2.html" target="iframe1" onclick="changeSrc2()">切换到页面二</button> <a href="1.html" target="iframe1">切换到页面一</a> <a href="2.html" target="iframe1">切换到页面二</a> </div> <div> <iframe name="iframe1" id="iframe1" src="1.html"> </iframe> </div> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwydsj.html