Wednesday, July 09, 2008

JavaScript Open New Window

Here's the JavaScript I use when I want to spawn a new window:

Using a button:
<input value="submit" 
onclick="javascript:window.open
('NewPage.html', 'WindowName',
'width=450, height=350, top=100, left=100, toolbar=0,
menubar=0,location=0,status=0,scrollbars=0,resizable=0');"
type="button">
Using a link:
<a href="#"
onclick="javascript:window.open
('NewPage.html','WindowName',
'width=450, height=350, top=100, left=100,
toolbar=0, menubar=0, location=0, status=0, scrollbars=0, resizable=0');
return:false;">New Window</a>
The return:false; at the end keeps the link click from completing, so you can use a # as the link destination.

No comments: