源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

异步加载script的代码

  • 时间:2020-01-17 07:50 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:异步加载script的代码
通过iframe 异步加载script 通过异步请求另一页面的script 是不执行的,只返回html 原文件,因为返回的文本没有经过浏览器的解析执行。 看代码 a1.html
[u]复制代码[/u] 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>无标题页</title> </head> <script type="text/javascript"> function testClick() { document.getElementById("tsrc").src="a2.html" } </script> <body> <div style="display:none"><iframe id="tsrc"></iframe></div> <input id="Button1" type="button" value="异步加载script" onclick="testClick()"/> </body> </html>
a2.html
[u]复制代码[/u] 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>无标题页</title> </head> <body> <script> alert('我是异步script'); </script> </body> </html>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部