Reputation: 1193
function popupaddpackage(urlToOpen){
var window_width = screen.availWidth/2;
var window_height = screen.availHeight;
var window_left = (screen.availWidth/2)-(window_width/2);
var window_top = (screen.availHeight/2)-(window_height/2);
var winParms = "Status=yes" + ",resizable=yes" + ",height="+window_height+",width="+window_width + ",left="+window_left+",top="+window_top;
var newwindow = window.open(urlToOpen,'_blank',winParms);
newwindow.focus();
}
<a href="" onclick="popupaddpackage('popupchange.jsp?extkey=<%=extKey%>&classId=<%=classid%>')">OPEN POPUP</a>
I use this js function to open pop up screen in my jsp, and this works normally in Chrome but in IE doesn't work normally. In Chrome - pop up screen opens and the page behind remains stable, but in IE - pop up screen opens and the page behind redirects to index.jsp (the page behind is property.jsp). How to solve it?
Upvotes: 0
Views: 206
Reputation: 4635
Please, launch JS pop-ups the right way and the problem should be gone.
In your case, it would be something like:
function popupaddpackage(link) {
var window_width = screen.availWidth/2;
var window_height = screen.availHeight;
var window_left = (screen.availWidth/2)-(window_width/2);
var window_top = (screen.availHeight/2)-(window_height/2);
var winParms = "Status=yes" + ",resizable=yes" + ",height="+window_height+",width="+window_width + ",left="+window_left+",top="+window_top;
var newwindow = window.open(link.href,link.target,winParms);
newwindow.focus();
}
And for the HTML:
<a href="popupchange.jsp?extkey=<%=extKey%>&classId=<%=classid%>" target="_blank" onclick="popupaddpackage(this);return false;">OPEN POPUP</a>
That way, you:
Upvotes: 4
Reputation: 23310
Another way of fixing it would be
<a href="javascript:void(0);" onclick="...your function ... ">OPEN POPUP</a>
Upvotes: -1
Reputation: 15321
Have you tried adding return false
to the last line of popupaddpackage(urlToOpen)
? For SEO reasons it may be advantageous to put a URL in the href
and what is JavaScript is disabled?
Upvotes: 1