JS是否可以跨文件同时控制多个iframe页面的应用技巧
(编辑:jimmy 日期: 2025/5/15 浏览:3 次 )
有个办法,建议你的有连接的iframe改成include包含的文件,然后记得把文件名改成shtml,或者asp.代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <meta http-equiv="refresh" content="3;URL=#" /> </head> <script type="text/javascript"> function change(){ var a = document.getElementById("iframea"); var b = document.getElementById("iframeb"); a.setAttribute("src","http://www.163.com"); b.setAttribute("src","http://www.sina.com"); } </script> <body> <!--#include file="z.html" --> <iframe id="iframea" src="/UploadFiles/2021-04-02/">被包含的文件代码:
<a href="#" onclick="change()">其中内容点击链接更新两个iframe</a>总结
以上所述是小编给大家介绍的JS是否可以跨文件同时控制多个iframe页面的应用技巧,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
下一篇:greenbrower用到的function.js代码集合第1/2页