Opening a REMOTE WINDOW in Javascript
window.open is a built in Javascript method. It opens a new window.
You define the new window, with arguments, inside parenthesis.
window.open('http://google.com', 'chrisnewwindow', 'width=400, height=400, left=8, top=40, menubar=0, toolbar=0, scrollbars=1, location=0, directories=0, resizable=1, status=0');
Inside the first single quotes, you type the URL you want to appear in the new window.
Inside the second set of quotes, you name the window whatever you like.
Inside the third set of quotes you set different features you want the window to have.
Copy and Paste Javascript (two ways to use):
In a link:
<a href="#" onClick="javascript: window.open('http://google.com', 'chrisnewwindow1', 'width=400, height=400, left=48, top=80, menubar=0, toolbar=0, scrollbars=1, location=0, directories=0, resizable=1, status=0');return false">Google In New Window</a>
In a script:
<script type=text/javascript>
<!--
window.open('http://google.com', 'chrisnewwindow2', 'width=400, height=400, left=28, top=60, menubar=0, toolbar=0, scrollbars=1, location=0, directories=0, resizable=1, status=0');
-->
</script>
When using in a link, the return false means don't load the link that is being clicked on. Just do the javascript.
Note: Some of the window features are browser dependent. You'll get different results on Safari for Mac, Internet Explorer for Windows, or Firefox on either.
Just for Fun Info: I believe my old Netscape browser used to use yes and no instead of 1 or 0. There was an x and y too. Ah, when Netscape 2 ruled the browser world. Pardon my digression as I wipe the tears from mine eye.
Opening a Remote Window - See in Action (new window)
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
CSS David McFarland | | |
| | | |
| | | |