主要的缺点一共有两个:
1.iframe会影响onload加载
2.iframe和主页共用同一个连接池,会影响页面加载
解决办法:用js动态的加载iframe
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
#buttonA {
display: block;
width: 120px;
height: 35px;
background-color: gray;
line-height: 35px;
text-align: center;
}
#buttonA:hover{
color:white;
background-color: black;
cursor:pointer;
}
</style>
<!-- <script type="text/javascript" src="js/jquery1.11.3.js"></script>-->
</head>
<body>
<a id="buttonA" >Click</a>
<iframe id="testFrame" src="http://www.baidu.com" width="100%" height="500"></iframe>
<script>
/*$(document).ready(function(){
$("#buttonA").click(function(){
$("#testFrame").attr("src","http://www.sina.com.cn");
});
});*/
window.οnlοad=function(){
var button=document.getElementById("buttonA");
var iframe=document.getElementById("testFrame");
button.οnclick=function(){
console.log(iframe);
iframe.src="http://www.sina.com.cn";
};
};
</script>
</body>
</html>
主要的知识点及时console.log打印,这个是安装了Firebug的Firefox的专利,不过后来欧朋浏览器添加了dragonfly功能,功能和Firebug类似,关于console.log的知识继续学习中……