How to open a new window when clicking on a hyperlink?
It is much better to bind this to a hyperlink unobtrusively, like:
Html
<a href="mypopup.htm" id="popup">This will open in a new window</a>
JavaScript
window.onload = function() {
document.getElementById("popup").onclick = function(){
return !window.open(this.href, "pop", "width=200,height=600");
}
}
The advantage of this approach is that you need to specify a hyperlink in your HTML file, and if JavaScript is disabled or generates an error for some reason, it will refuse to use the standard hyperlink.
source to share
Creating a new window with JavaScript (including window size)
http://www.fontstuff.com/frontpage/fptut06.htm
source to share
var user_window=window.open('http://www.someplace.com','someplace_window_name','toolbar=no,directories=no,location=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,width=1024,height=768');
user_window.focus();
The user click must initiate this, or it will be blocked by most pop-up blockers. This works in all browsers I have had to support, including IE6 +, FF, Opera, Safari.
The focus bit ensures that the new window is brought to the front.
As an alternative to the popup, I suggest the Dialog plugin for JQuery.
This is what I replaced 90% of my popups.
Your popup becomes popover (linked in the original window) and this is never blocked by the popover blocker as far as I can tell. The Dialog plugin lets you drag popovers, look and feel, and a lot of other cool stuff.
source to share