English 中文(简体)
从一机起,在母体内打字箱
原标题:call Fancybox in parent from iframe

我有两页,我的指数.html和社会.html。 我清理了我的指数,只剩下了需要。 我试图做的是掌握社会形象。 html和点击时,它将打开租赁箱并显示它,但以指数表示。 由此产生的错误是:

Uncaught TypeError: Property  showImage  of object [object DOMWindow] is not a function
(anonymous function)social.html:103
  onclick 

这是我的指数。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript" src="js/video.js"></script>
<script type="text/javascript">
        function showImage(image) {
            $.fancybox( <img src="img/  + image +  " alt="" border="0" /> );
        };
</script>

</head>

<body>
<iframe src="social.html" scrolling="no" border="0" width="579" height="505" allowtransparency="true"></iframe>
</body>
</html>

摘录

 <img src="img/picture1.jpg" alt="" class="thumbs" onclick="parent.showImage( picture1.jpg );"/>

PS: both pages are on same domain... EDIT: video.js -> this is from fancybox I didn t make this.

jQuery(document).ready(function() {

    $(".video").click(function() {
        $.fancybox({
             padding        : 0,
             autoScale      : false,
             transitionIn   :  none ,
             transitionOut  :  none ,
             title          : this.title,
             width          : 640,
             height         : 385,
             href           : this.href.replace(new RegExp("watch\?v=", "i"),  v/ ),
             type           :  swf ,
             swf            : {
             wmode              :  transparent ,
             allowfullscreen    :  true 
            }
        });

        return false;
    });



});
最佳回答
问题回答

由于星号上是不同的网页。 因此,Jquery正在指数.html,但成像是这样,为什么JQuery可以进入图像。

或许使用类似的东西...... 但是,一心一意认为它会发挥作用。

索引.html

$(document).ready(function () {
    //function to active fancybox on the thumbs class inside the iframe
    //Not sure it works on iframes, probably it doesnt.
    $("#iframeID.thumbs").fancybox();
});

And add the id to the iframe declaration < iframe src="social.html" id="iframeID" etc... rest of properties>

But, my advice is to use divs instead of iframes. You also should remove the onclick from the image for non-obstrusive Javascript.

Check the tutorial: http://fancybox.net/howto If you want a similar tutorial in spanish you can check my site too.

你不需要从胎箱提升到1.3.x,你也没有在座机页上需要ancy子。

<>光>

<a href="#" class="fancylink" data-url="www.example.com">Some link</a>

$( .fancylink ).click(function() {
    var url = $(this).attr("data-url");
    parent.show_fancybox(url);
});

Parent:

function show_fancybox(url) {
    $.fancybox({
         type           :  iframe ,     
         width          : 640,
         height         : 480,
         href           : url       
    });
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签