PDA

View Full Version : Link Open in new window....


kramer336
12-09-2002, 08:42 PM
Here is a script Ive been playing around with. It will randomly display a banner at the top of a page. Im stuck on how to make the links for the banners open in a new blank window. Can anyone help?

Here is the HTML link... http://www.saweddings.com/*****enbanner.htm

Im pretty sure,,, its just one simple line.. but im not sure~!~


<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language="JavaScript">


i = 2 // Number of banners that you have
banner1= new Image();
banner1.src = "http://saweddings.com/images/Banners/animated-bannergif.gif";
banner2 = new Image();
banner2.src = "http://saweddings.com/images/mock-banner.gif";

links = new Array
links[1] = "http://simonsaysstudios.com"
links[2] = "http://cnn.com"

description = new Array
description[1] = "LINK DESCRIPTION #1"
description[2] = "LINK DESCRIPTION #2"

function randombanner(){
var randomnumber = Math.random();
i = Math.round( (i - 1) * randomnumber) + 1;
document.banner.src = eval("banner" + i + ".src");
}

function startTime(){

var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;
closeTime+=7; // How many seconds til the next rotation
Timer();

}

function Timer(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
curTime=hours*3600+mins*60+secs
if (curTime>=closeTime){
if (i < 2){ // The number 2 is the amount of banners that you have
i++;
document.banner.src = eval("banner" + i + ".src");
}
else{
i = 1;
document.banner.src = eval("banner" + i + ".src");
}
startTime();
}
else{
window.setTimeout("Timer()",1000)}

}

function clickLink(){
top.location = links[i]
}

function descript(){
window.status = description[i]
}

// -->
</script>
</head>

<body onLoad="randombanner(); startTime();">
<a href="" onClick="clickLink(); return false;" onMouseOver="descript(); return true;" onMouseOut="window.status=''">
<img src="images/Banners/animated-bannergif.gif" border=0 name="banner" width="468" height="60"></a>

</body>

</html>



OPPS NO CURSING>.. http://www.saweddings.com/bnbanner.htm

beetle
12-09-2002, 08:48 PM
One line? Yes
Simple? Yes

<a href="" onClick="clickLink(); return false;" onMouseOver="descript(); return true;" onMouseOut="window.status=''" target="_blank">

:D

kramer336
12-09-2002, 09:03 PM
here is the updated page:

http://www.saweddings.com/sweetbanner1.htm

It didnt open a new win for me.. am i doing something wrong?

steve

beetle
12-09-2002, 10:18 PM
Oh, I'm sorry, I was assuming the banner thingy modified the href of the link. Still a simple change

from this:function clickLink(){
top.location = links[i]
}to this:function clickLink(){
window.open(links[i],'_blank');
}:D

kramer336
12-11-2002, 06:03 PM
Thanks Beetle! U da Bomb! :thumbsup: