jquery交互式弹出窗口

时间:2010-10-19 09:39:01

标签: jquery-plugins jquery

任何人都可以为jquery pop窗口(不是div元素)插件提供链接。在窗口打开之前,在鼠标悬停/单击事件上打开窗口并在链接上加载图像。不需要灯箱。

示例:广告的infolink网址

1 个答案:

答案 0 :(得分:1)

如果你想使用javascript与子窗口和父窗口进行交互,那么也许你应该从子窗口查看window.opener属性来调用parent全局JS函数。像
在父窗口和子窗口中定义全局函数
function Connector(msg){
$('body').append(msg+'<br/>');
}

从父级,保存您打开的窗口实例 var child = window.open('child.html');
窗口打开后[你必须弄清楚如何等待]呼叫
child.Connector('parent calling child');

同样,从子窗口的父窗口中的子调用Connector()函数,如
window.opener.Connector('child calling parent');

希望这对你有所帮助,下面是我用过的html和JS 对于父html

function Connector(msg){
    $('body').append(msg+'
'); } $(document).ready(function(){ var child = null; $('#test_btn').bind('click', function(){ var newwin = window.open('new_wind.html'); $('#call_child').show(); child = newwin; if(window.console){ console.log($child.contents().find('body').length); console.log(newwin); console.log($child); } return false; }); $('#call_child').bind('click', function(){ if(child){ child.Connector('parent calling child'); } }); });

`

  Hello World

   `

对于孩子:

$(document).ready(function(){
        if(window.opener){
            window.opener.Connector('child calling parent');
        }
        else{
            alert('no parent: window.opener');
        }
    });
    function Connector(msg){
        $('body').append(msg+'
'); }
相关问题