PDA

View Full Version : Making links in New Window


deankeen
02-23-2008, 03:10 AM
Hello! Glad to have found this website and forum!!! It's really awesome! Anyway, I am using the code below (also found on this page: http://www.javascriptkit.com/script/cut144.shtml) and was wondering how I could get it so that each link loads in a new window. If someone could help me with this, I'd really appreciate it! Thanks!!


<p align="center"><span style="vertical-align: text-top; font-weight: 700">
<font size="6"><script language="JavaScript">

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="ggaf1.gif"
myimages[2]="ggaf2.gif"
myimages[3]="ggaf3.gif"
myimages[4]="ggaf4.gif"
myimages[5]="ggaf5.gif"
myimages[6]="ggaf6.gif"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]="http://link.com"
imagelinks[2]="http://link.com"
imagelinks[3]="http://link.com"
imagelinks[4]="http://link.com"
imagelinks[5]="http://link.com"
imagelinks[6]="http://link.com"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>

rangana
02-23-2008, 03:20 AM
Just change your document write to these code:
document.write('<a href='+'"'+imagelinks[ry]+'"'+'target="_blank"><img src="'+myimages[ry]+'" border=0></a>')

See if it helps :D

deankeen
02-23-2008, 03:38 AM
Um dude, you rock! :) Thanks for the help. I can't believe I didn't see that there. I should've looked at the code better. You guys are awesome! Thx rangana

rangana
02-23-2008, 03:39 AM
No problem..you're welcome :D