View Full Version : Get popups to open with target

06-24-2006, 11:08 AM

I know how to make a new window appear by using...

<script language="javascript">function newwin() { window.open("http://www.foo.com","newwin","width=250,height=300") } </script>
<a href="javascript:newwin()">New Window</a>

But in this specific instance, I want to do it using:

<a href="http://www.foo.com" target="newwin">

I remember reading that this was possible but I can't work out the script which goes in the HEAD for it!

Thanks so much for anyone who can help :)


06-24-2006, 05:36 PM
Something like this?

<script type="text/javascript">
function newwin(url)
var thewin = window.open(url,'thewin','width=250,height=300')
if(thewin) thewin.focus();
function setWin()
var thelinks = document.getElementsByTagName('a');
for(var i = 0; i < thelinks.length; i++)
if(thelinks[i].getAttribute('target') == 'newwin')
thelinks[i].onclick = function()
return false;
window.onload = setWin;
<a href="http://www.google.com" target="newwin">google</a><br>
<a href="http://www.yahoo.com" target="newwin">yahoo</a><br>
<a href="http://www.codingforums.com">codingforums</a>

06-25-2006, 01:57 PM
You're a genius... thanks so much!!:) :)


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum