开发者

javascript popup reloads parent page -

开发者_JAVA百科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>

should be

<a href="foo.html" onclick="newPop(); return false;">Foo</a>

or (as newPop() always returns false):

<a href="foo.html" onclick="return newPop();">Foo</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜