就是说
<iframe src="http://www.baidu.com" id="if1"></iframe>然后点击一个按钮
就能把这个IFRAME 改成src为空
而且还能为这个iframe 写入新的页面我尝试过:
document.getElementById("if1").src="" ::提示没有访问权限 document.frames["if1"].location.href="about:blank";::这个可以 但是不能在写入新的页面了 :会出现未知错误
<iframe src="http://www.baidu.com" id="if1"></iframe>然后点击一个按钮
就能把这个IFRAME 改成src为空
而且还能为这个iframe 写入新的页面我尝试过:
document.getElementById("if1").src="" ::提示没有访问权限 document.frames["if1"].location.href="about:blank";::这个可以 但是不能在写入新的页面了 :会出现未知错误
<html>
<head>
<script type="text/javascript">
window.onload = function(){
document.getElementById('click').onclick = function(){
var if1 = document.getElementById('if1').contentWindow; //用来加载新页面
var ff = document.getElementById('if1'); //用来把src设置成''
ff.src = '';
if1.location = 'http://www.google.com#';
};
};
</script>
</head>
<body>
<iframe src="http://www.baidu.com" id="if1"> </iframe>
<input type="button" id="click" value="click" />
</body>
</html>