Opening Links in a New Window

Published in Website Design on Thursday, 26 February 2009  |   Subscribe to rss feed for Opening Links in a New Window (rss logo graphic) Post RSS

This is a simple script that opens a link in a new browser window.

You can open links in an existing open window, or a brand new one. 

View The Sample

Click me to open a new window

Click me to replace the content of the first window with Google

Click me to open differrent window with Google

Get The Script

Put this code in the <head> of your page (or external JS file):

<script type="text/javascript">

function openWindow(theURL,winName) {
window.open(theURL,winName);
}

</script>

 

Use this code in the <body> of your page:

<p><a href="javascript:void()" onClick="openWindow('http://www.webfertile.co.uk', 'theNewWindow');">Click me to open a new window</a></p>

<p><a href="javascript:void()" onClick="openWindow('http://www.google.co.uk', 'theNewWindow');">Click me to replace the content of the first window with Google</a></p>

<p><a href="javascript:void()" onClick="openWindow('http://www.google.co.uk', 'anotherNewWindow');">Click me to open differrent window with Google</a></p>


All resources written by The WebFertile Team.

Whatever your business needs, one of our highly trained small business development experts is sure to be able to help.

 





Comments


There are currently no comments to display.





Tags

web designers, javascript, nottingham