iframe的缺点

主要的缺点一共有两个:

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的知识继续学习中……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值