Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a popup window being opened by my application as follows:

function newPopup(url, windowName) {
    window.open(url,windowName,'height=768,width=1366,left=10,top=10,titlebar=no,toolbar=no,menubar=no,location=no,directories=no,status=no');
}
<a href="JavaScript:newPopup('lobby.do', 'lobby');">Enter Lobby</a>

Inside that popup window, I want the user to have the ability to move that popup's window location by clicking a link:

<a href="game.do">New Game</a>

However, when click this link in the popup window, the popup is automatically closed and the redirect does not happen. I've tried adding an onClick and using javaScript:window.location, but get the same results. Any idea what could be causing this? I've tested in both Chrome and Firefox.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
505 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just set the target of the link to the popup's name.

<a href="game.do" target="lobby">New Game</a>

Or save the value returned from window.open and set its .location.

function newPopup(url, windowName) {
    return window.open(url,windowName,'height=768,width=1366,left=10,top=10,titlebar=no,toolbar=no,menubar=no,location=no,directories=no,status=no');
}

<a onclick="window.lobby=newPopup('lobby.do', 'lobby'); return false;" href="#">Enter Lobby</a>
<a href="window.lobby.location='game.do'; return false;" href="#">New Game</a>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...