将A标签的href用iframe打开(JS)

修改后的。。

 

ContractedBlock.gif ExpandedBlockStart.gif Code
  1 ///<reference path="jquery-1.2.6-vsdoc-cn.js" />
  2 /*
  3 *这个JS文件的作用是将A标签的href用iframe打开
  4 *              2009年7月17日
  5 *                 zzjj296
  6 */
  7 $(document).ready(function(){
  8         $(".zMode").each(
  9             function(index,obj){
 10                 obj.onclick=function(){
 11                     _zModeFn(obj.href2 ,obj.zWidth);
 12                 }
 13             }
 14         )
 15     }
 16 );
 17 function _zModeFn(Url,Width){
 18     var url="http://www.baidu.com/";
 19     var width=780;
 20     var imgPath="../images/close.gif";
 21     if(Url!=null){url=Url;}
 22     if(Width!=null){width=parseInt(Width);}
 23     
 24     var div = document.createElement("div");
 25     with(div.style)
 26     {
 27         border="1 solid #999";
 28         left=0;
 29         top=0;
 30         position="absolute";
 31         filter="alpha(opacity=80)";
 32         backgroundColor="#000"
 33         zIndex=1;
 34     }
 35     div.style.height=800>document.body.scrollHeight?800:document.body.scrollHeight;
 36     
 37     div.style.width=document.body.scrollWidth;
 38     
 39     document.body.appendChild(div);
 40     
 41     var div2=document.createElement("div");
 42     with(div2.style)
 43     {
 44         border="4 solid #777777";
 45         position="absolute";
 46         zIndex=2;
 47     }
 48     div2.style.width=width;
 49     div2.style.height=100;
 50     div2.style.top=30;
 51     
 52     div2.style.left=20;
 53     document.body.appendChild(div2);
 54     
 55     var f1=document.createElement("iframe");
 56     f1.src=url;
 57     f1.width=parseInt(div2.style.width)-8;
 58     var IntervalId = window.setInterval(
 59     function(){
 60         reinitIframe(div2,f1);
 61     }
 62     , 200);
 63     div2.appendChild(f1);
 64     
 65     var divClose=document.createElement("div");
 66     with(divClose.style)
 67     {
 68         width=12;
 69         height=12;
 70         position="absolute";
 71         backgroundImage="url("+imgPath+")";
 72         fontSize="5px";
 73         lineHeight="5px";
 74         
 75         top=parseInt(div2.style.top)-6;
 76         left=parseInt(div2.style.left) + parseInt(div2.style.width)-4;
 77         zIndex=3;
 78     }
 79     document.body.appendChild(divClose);
 80     
 81     divClose.onclick=function(){
 82         //销毁
 83         window.clearInterval(IntervalId);//自动高度
 84         div.parentNode.removeChild(div);
 85         div2.parentNode.removeChild(div2);
 86         divClose.parentNode.removeChild(divClose);
 87     }
 88 }
 89 
 90 function reinitIframe(obj,iframe){
 91 
 92     try{
 93         var bHeight = iframe.contentWindow.document.body.scrollHeight;
 94         var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
 95         var height = Math.max(bHeight, dHeight);
 96         iframe.height =  height;
 97         obj.style.height=height;
 98     }catch (ex){alert(ex.message);}
 99 }
100 

 

 

 

 

 


下载地址:zMode.rar

转载于:https://www.cnblogs.com/jgjgjg23/archive/2009/07/16/1524972.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值