Reputation: 117
Following works perfectly in Firefox:
I have following in javascript:
function newPopup(url) {
popupWindow = window.open(url, 'popUpWindow', 'height=700,width=800,left=10,top=10');
}
And 2 anchor links on my webpage:
<a href="JavaScript:newPopup('http://blablabla/ReferenceManua.pdf#page=31');
Reference Manual 31</a>
<br />
<a href="JavaScript:newPopup('http://blablablaReferenceManua.pdf#page=61');">
Reference Manual 61</a>
When clicking on the 1st link, a new window opens, the pdf file is loaded, the url indicates it has to jump to page 31 and so it jumps to page 31 --> OK
When then clicking on the 2nd link, the same window is used, the url indicates it has to jump to page 61 and so it jumps to page 61 --> OK
In chrome however... When clicking on the 1st link, a new window opens, pdf file is loaded, the url indicates it has to jump to page 31 and so it jumps to page 31 --> OK
but when clicking on the 2nd link, the same window is used, the url indicates it has to jump to page 61 but it stays on page 31 --> ??
In IE even worse: A new window is created everytime i click on either link. Jumping to the requested page doesn't happen
How to solve this?
thank you
Upvotes: 2
Views: 5823
Reputation: 4775
Since you are using the same window name thats why it opens in same window If you want a separate one then you can try this Demo
var randomnumber = Math.floor((Math.random()*100)+1);
window.open('yoururl',"_blank",'PopUp'+randomnumber+',scrollbars=1,menubar=0,resizable=1,width=850,height=500');
Upvotes: 0
Reputation: 39777
I believe forcing window to close (if it is open) should solve the issue. Change your JS code to:
var popupWindow;
function newPopup(url) {
if (popupWindow) popupWindow.close();
popupWindow = window.open(url, 'popUpWindow', 'height=700,width=800,left=10,top=10');
}
Upvotes: 1