从iframe到父级的Fancybox

时间:2012-03-27 15:46:21

标签: javascript html fancybox

我正在使用fancybox插件,我正在尝试将其发送到父窗口。我让它在一个页面上工作,但当我把它带到另一个页面,它是幻灯片的一部分时,我收到一个错误,它“不是一个功能”。根据我的理解,我需要做的就是在父页面上实现插件。如果有人能帮助我找出为什么会引起这个错误,我真的很感激!

第1页

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="http://www.localdtvdealer.com/page.aspx?QS=5c591a8916642e737e93c01412d56d5ae266a22b4f55b9f9a54ed7191c748091" />
<link rel="stylesheet" type="text/css" href="http://image.iloqal.com/lib/fe60157077600275741d/m/1/zipCodeWindowCSS.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="http://www.localdtvdealer.com/page.aspx?QS=5c591a8916642e73c41f320542ef4912ec966ef60dc239352e9e3ff3a33d77cf"></script>

<link rel="stylesheet" type="text/css" href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/DTVLBjqueryfancybox.css" />
<script type="text/javascript" src="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/DTVLBjqueryfancybox2.js"></script>
<script type="text/javascript">
var corpID = "44444";

$(document).ready(function() {
      if($("#contentPane").length && getCookie("Offer"))
        {
            SetIFrameSource("contentPane","http://www.localdtvdealer.com/BMI/Carousel/iframe/?cid=" + corpID);
            $("#lblLocation").text(getCookie("Location"));
        }

    });

</script>
</head>
<body>
<iframe src="" width="720" height="446" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" id="contentPane"></iframe>
</body>

第2页

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="http://image.iloqal.com/lib/fe60157077600275741d/m/1/ZipCodeWindowLogoExplosion.js"></script>

<link rel="stylesheet" type="text/css" href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/DTVLBjqueryfancybox.css" />
<script type="text/javascript" src="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/DTVLBjqueryfancybox2.js"></script>

<script type="text/javascript">

    function reqParam( name )
        {
            name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
            var regexS = "[\\?&]"+name+"=([^&#]*)";
            var regex = new RegExp( regexS );
            var results = regex.exec( window.location.href );
            if( results == null )
                return "";
            else
                return results[1];
        }

   $(document).ready(function() {
      if($("#contentPane").length && getCookie("Offer"))
        {
            SetIFrameSource("contentPane","http://www.localdtvdealer.com/" + getCookie("Offer").toUpperCase() + "LogoExplosion");
            $("#lblLocation").text(getCookie("Location"));
        }
        setSrcDynamically();
    });


  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

</head>

<body>
<iframe name="base" id="base" class="iframe" src="" overflow="auto;" width="712px" height="397px;" frameborder="0"></iframe>
<script type="text/javascript">
<!--
        function setSrcDynamically()
            {
                var pvalue=reqParam('p');
                var i = document.getElementById('base');
                i.src="http://www.localdtvdealer.com/justintest3/#"+pvalue;

            }
        //-->
    </script>
</body>

1 个答案:

答案 0 :(得分:2)

固定!

基本上我的目标是错误的父母。我将iframe定位为父级。通过为框架添加另一个“.parent”对象来修复它。

 window.parent.parent.$.fancybox

而不是

 window.parent.$.fancybox

活泉!