Cool Link

Wouldn't it be nice if a site linked to your page you could provide them with a standard link yet when used your page opened in a new window with your custom settings? Even better, left the user on the same page that provided the link in the old window. People that link to you might like you better (you don't take people away from their site). Normally how the link opens is up to the site that creates the link. In order for the linking site to open your site in a new window with specific options(width,height,toolbars...) requires complex code which they probably don't want to add. Or at least you thought.
No it doesn't. Here is a trick so you can use a standard "http://somesite.com/mylink.htm" reference and have your page open in a "special" window. Please note that this only applies to links. If some one types the page location in their browser this may not work(rare). 

The first example is the minimum code to accomplish the task. This is sort of a "dummy" file. You don't even need HTML tags. Just paste this code into a file and save with an ".htm" file extension. Adjust the "mypage.htm" reference to the page you really want to appear in the popup. Now anytime someone wants to link to your page provide them with a link to this special little file you created instead of the real page. It is important to go back in history before opening new window to make sure the new window opens in front. 

<script type="text/javascript"> <!-- always comment code out unless sure browser supports script. history.back() window.open("mypage.htm") // --> </script>

Demonstrate - Opens new window... the link requires no special "Target" or script code. The window size, location and window settings will use whatever is the browser default. Close the window when done. This window is still here. To tell if you are viewing the popup... It looks like "Printer Friendly" view(there is no logo, themes or toolbar). The link code used for this demo is 
<a href="coollinkdemo1.htm">Demonstrate</a>. 

You could adjust window settings... This example sets the new windows width to 400px, height to 400px, positions it, displays only the toolbar and scrollbars and is not resizable. The settings "top=50,left=100,screenX=50,screenY=100" are to support window positioning in both Netscape(screenX/screenY) and Explorer(top/left).

<script type="text/javascript"> <!-- history.back() myparms="width=400,height=400,top=50,left=100,screenX=50,screenY=100,toolbar,scrollbars" myhome=window.open("mypage.htm","",myparms) // --> </script>

Demonstrate - this will open a new window with specified settings. Our example loads this page in the new window but you could use any page. The link code used for this demo is 
<a href="coollinkdemo2.htm">Demonstrate</a>. 

You could get fancy and determine the window settings based on users configuration(like different screen resolutions), center the window, dynamically write the new window content from script then finally do the "Back". If you can do that this little function is simple to add. This site has several examples of the fancy concept.

Of course you should put more content in the "dummy" page to handle users that do not have JavaScript enabled browsers... Probably a link with a target of new window will suffice. Perhaps the user needs JavaScript to use your site. In that case this "dummy" page is a great place to tell them.

Anyway, I hope this helps those that want it.