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.
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.
Share Improve this question edited Jan 15, 2013 at 19:25 gen_Eric 227k42 gold badges303 silver badges342 bronze badges asked Jan 15, 2013 at 18:20 SteveKerrSteveKerr 551 gold badge2 silver badges5 bronze badges 1- 1 So is this link in the main page or in the pop up window? – gen_Eric Commented Jan 15, 2013 at 19:26
4 Answers
Reset to default 3Just 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>
What you need to do to open it in a new window is add target_blank
at the end of a html
link like this:
<a href="http://link-to-your-game" target="_blank">Enter Lobby</a>
why not to use ajax:
<a onclick="ajaxcall_to_newpage()"> click here to update the content </a>
and your ajax function requesting a new content from server and rendering it to html:
..
}).done(function(data){
$('#your_div_of_pop_up').text(data);
});
job is done!
If I understand correctly what you need is to name your popup. Then you can reference that popup to change the content of it.
All you need is a bit of JavaScript
function createPopup(url) {
newwindow=window.open(url,'testWindow','height=800,width=600');
if (window.focus) {newwindow.focus()}
return false;
}
That can be used like this :
<a href="#" onclick="createPopup('http://www.google.')" target="mine">use google</a>
<a href="#" onclick="createPopup('http://www.stackoverflow.')" target="mine">use stackoverflow</a>
So from the main window you can control your popup.