Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie to JS

Status
Not open for further replies.

drmilk

Programmer
Nov 22, 2007
1
US
Ive got a cycling banner with links. I would like to get these links to open into a new window, but i cant seem to amke it work. Here is my HTTP page:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"<html>
<head>
<frame name="view">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Viewing page</title>
<script src="bannerlinks.js"
language="javascript" type="text/javascript">
</script>
</head>

<body>
<div align="center">
<a href="" target="_blank"><img src="images/anime.gif" alt="ad banner" width="500" height="99" border="0" align="baseline" id="adBanner" /></a>
</div>
</body>
</html>



This is the script im using:


window.onload = initBannerLink;

var adImages = new Array("images/anime.gif","images/ninja.jpg","images/newegg.gif","images/hswlogo.jpg");
var adURL = new Array("var thisAd = 0;

function rotate() {
thisAd++;
if (thisAd == adImages.length) {
thisAd = 0;
}
document.getElementById("adBanner").src = adImages[thisAd];

setTimeout("rotate()", 3 * 1000);
}

function newLocation() {
document.location.href = " + adURL[thisAd];
return false;
}

function initBannerLink() {
if (document.getElementById("adBanner").parentNode.tagName == "A") {
document.getElementById("adBanner").parentNode.onclick = newLocation;
}

rotate();
}

Can anyone tell me what im missing to get this to open in a new window? I would like it to not be a popup because of all the blockers. Is it because im using frames, ive never really done much with frames cuz i hate them so.
 
change this...
Code:
function newLocation() {
    document.location.href = "[URL unfurl="true"]http://"[/URL] + adURL[thisAd];
    return false;
}
to...
Code:
function newLocation() {
    window.open("[URL unfurl="true"]http://"[/URL] + adURL[thisAd], "MyWindow", "");
    return false;
}

see this site for more info...


~Nate_Bro


Code Snippets just because
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top