Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- JS q - window.open positioning; also, window closing


moonbiter - 7:41 pm on Aug 27, 2002 (gmt 0)


Just code portability. If you want to put the window open into a function, you can call it from a lot of different links on the page and just pass it arguments in the function call. So you could have:

function openWindow(url) {
var window_name = window.open(url,'window_name','screenX=0,screenY=0,top=0,left=0');
}

and call it like:

<a href="#" onclick="openWindow('foo.htm')">Foo link</a>
<a href="#" onclick="openWindow('foo2.htm')">Foo link 2</a>
<a href="#" onclick="openWindow('foo3.htm')">Foo link 3</a>

and so on.

<added>
Plus, you'll need to put the window into a variable to get the window.close() method to work from another window.
</added>


Thread source:: http://www.webmasterworld.com/javascript/182.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com