jquery操作iframe中的HTML 在IE6、Mozilla Firefox 正常

以下为ASP的大概内容:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="lsq_js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

  function getIframeDom(id){
    return window.document.getElementById(id).contentDocument||window.document.getElementById(id).contentWindow.document;
  }


  $(document).ready(function(){
    $(getIframeDom("frame_smallPicture")).find(".img1_opacity").css("opacity", 0.7);
    $(getIframeDom("frame_smallPicture")).find(".img1_opacity").mouseover(function (){$(this).css("opacity", 1);});
    $(getIframeDom("frame_smallPicture")).find(".img1_opacity").mouseout(function (){$(this).css("opacity", 0.7);});
  });
</script>
</head>

<body>
  <div style="width:300px; height:200px;">
    <iframe name="I1" id="frame_smallPicture" src="Frameshanye.asp" width="750" height="650" border="0" frameborder="0"> 
      浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。
    </iframe>
  </div>
</body>
</html>

iframe的内容为:
<img style="border-width:0px; width:62px; height:62px; opacity:0.7;" class="img1_opacity" src="...">


说明:

window.document.getElementById(id).contentDocument 在Firefox使用

window.document.getElementById(id).contentWindow.document 在IE使用;

IE6、Mozilla Firefox 正常使用,但在chrome还是不正常


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值