不使用XMLHttpRequest实现异步加载 Iframe和script
时间:2022-05-31 09:24:05|栏目:JavaScript代码|点击: 次
调用页面如下:
<!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>
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script id="javascriptq" type="text/javascript"></script>
</head>
<body>
<input type="button" onclick="MoniAjax1();" id="btn" value="iframe" />
<input type="button" onclick="MoniAjax2();" id="script" value="script" />
<iframe id="iframe1" src=""></iframe>
<div id="result"></div>
</body>
</html>
<script type="text/javascript">
function MoniAjax1() {
$("#iframe1").attr("src", "iframeD.htm");
}
function MoniAjax2() {
$("#javascriptq").attr("src", "Scripts/scriptD.js");
}
</script>
iframeD.htm:是字符串就可以了
iframeD.htm
scriptD.js:是可以运行的js代码
$("#result").html("Scripts/scriptD.js");
复制代码 代码如下:
<!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>
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script id="javascriptq" type="text/javascript"></script>
</head>
<body>
<input type="button" onclick="MoniAjax1();" id="btn" value="iframe" />
<input type="button" onclick="MoniAjax2();" id="script" value="script" />
<iframe id="iframe1" src=""></iframe>
<div id="result"></div>
</body>
</html>
<script type="text/javascript">
function MoniAjax1() {
$("#iframe1").attr("src", "iframeD.htm");
}
function MoniAjax2() {
$("#javascriptq").attr("src", "Scripts/scriptD.js");
}
</script>
iframeD.htm:是字符串就可以了
iframeD.htm
scriptD.js:是可以运行的js代码
$("#result").html("Scripts/scriptD.js");
栏 目:JavaScript代码
下一篇:javascript通过元素id和name直接取得元素的方法
本文标题:不使用XMLHttpRequest实现异步加载 Iframe和script
本文地址:http://www.codeinn.net/misctech/203320.html