jQuery的magnificPopup插件如何通过自定义按钮关闭弹出窗口

来源:互联网 发布:淘宝刷流量会怎么样 编辑:程序博客网 时间:2024/06/06 02:38

打开magnificPopup窗口:

function showWin(Ids) {$.magnificPopup.open({items : [{src : currentDomain+'/igc/admin_selected_goods.html?Ids='+ Ids,type : 'iframe',height : '150px',width : '500px'}]});return $.magnificPopup.instance;}

关闭窗口

function closeWin(popWin){popWin.close();}

查看showWin方法可见,弹出窗口是iframe类型,换句话说要在新的页面关闭当前magnificPopup窗口,那么思路如下:

1、在A页面定义一个全局的_instance变量,并调用showWin方法将返回值赋给_instance变量;

var _instance;_instance = showWin(value);

2、在A页面定义一个closePopWin方法,在其中调用closeWin(_instance)方法;

function closePopWin(){closeWin(_instance);}

3、在打开的B页面调用A页面的closePopWin方法。

function closePop(){window.top.frames[1].frames[1].closePopWin();}

4、在B页面添加一个button调用closePop方法。

<input type="button" value="取消" onclick="closePop()"/>


0 0
原创粉丝点击