How To Change A Popup Window's Location
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=
Solution 1:
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>
Solution 2:
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>
Solution 3:
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!
Solution 4:
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.com')" target="mine">use google</a>
<a href="#" onclick="createPopup('http://www.stackoverflow.com')" target="mine">use stackoverflow</a>
So from the main window you can control your popup.
Post a Comment for "How To Change A Popup Window's Location"