javascript弹出窗口重新加载父页面- [英] javascript popup reloads parent page -
本文介绍了javascript弹出窗口重新加载父页面-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的程序中有一个弹出窗口功能很好,可以在加载子页面时重新加载父页面.有没有办法防止这种行为.
I have a popup function in a program that works well, be re-loads the parent page as it loads the child. Is there a way to prevent this behaviour.
// popup window function
function newPop(url, myWin, width, height, left, top, scrollbars) {
parms = 'toolbar=yes, scrollbars=no, location=no, menubar=no, resizable=no, width= ' + width + ' , height=' + height + ' , left= ' + left + ' , top= ' + top + ' , titlebar=no , scrollbars = ' + scrollbars ;
var newwin = window.open(url,myWin, parms);
newwin.resizeTo(width,height);
newwin.moveTo(0,0);
newwin.moveTo(left,top);
newwin.focus();
return false;
}
推荐答案
我的猜测是您不会取消触发弹出窗口的链接的默认行为:
My guess is that you do not cancel the default behavior of the link that triggers the popup:
<a href="foo.html" onclick="newPop();">Foo</a>
应该是
<a href="foo.html" onclick="newPop(); return false;">Foo</a>
或(因为newPop()
总是返回false):
or (as newPop()
always returns false):
<a href="foo.html" onclick="return newPop();">Foo</a>
这篇关于javascript弹出窗口重新加载父页面-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文