Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Help!


  • Please log in to reply

#1
TheRelief

TheRelief

    Member

  • Member
  • PipPip
  • 37 posts
I'm hoping there are some coders out there who can answer what for them is probably an idiotically simple question.

I have a Java script for rotating banners, but I want the links to open in a new browser window rather than opening in the current open window.

Thank you so much in advance for your help!

Here's the code below:

<HTML><HEAD>
<TITLE>Rotating banners with links</TITLE>

<script LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

if (document.images) {
ads = new Array(3);
ads[0] = "slipper_ad.gif";
ads[1] = "webnichebanner.jpg";
ads[2] = "sfcmp_ad.gif";
}

newplace = new Array(3);
newplace[0] = "http://www.silcom.com/~bevjack/"
newplace[1] = "http://www.webniche.com"
newplace[2] = "http://www.sfcmp.org"

var timer = null
var counter = 0

function banner() {
timer=setTimeout("banner()", 4000);
counter++;
if (counter >= 3)
counter = 0;
document.bannerad.src = ads[counter];
}

function gothere() {
counter2 = counter;
window.location.href = newplace[counter2];
}

// - End of JavaScript - -->
</SCRIPT>

</HEAD>
<BODY BGCOLOR="#FFFFFF" onload="banner()">

<a href="java script:gothere()"><IMG SRC="webnichebanner.jpg" WIDTH="468" HEIGHT="60" BORDER="0" NAME="bannerad"></a>

</BODY>
</HTML>
  • 0

Advertisements


#2
ssone

ssone

    Member

  • Member
  • PipPipPip
  • 301 posts
I gotta run, I can fix it later if no one else gets to it, but if you need it quick then you can just generate one here: ...::::...::..::..:::.::..::..
  • 0

#3
NullWolf

NullWolf

    Member

  • Member
  • PipPipPip
  • 225 posts
try changing line starting window.location.href
to
window.open(newplace[counter2])

Hrm... I dunno... can always try it, but may want to wait for ssone to give the correct answer...
  • 0

#4
ssone

ssone

    Member

  • Member
  • PipPipPip
  • 301 posts
Thats one way to do it :tazz:

window.open(newplace[counter2]);

In most cases you would want to keep the ";", but in this script it seems to work with or without it.

There are many other ways to modify this script including a document target "blank" so it opends in a new window.

Let me know if you need any more help with it, or other codes ;)
  • 0

#5
TheRelief

TheRelief

    Member

  • Topic Starter
  • Member
  • PipPip
  • 37 posts
I wanted to thank you all for your help!!! I got it working properly due to that script generator ssone sent the link to. Muchly appreciated!

I'm so glad I found this place!
  • 0

#6
ssone

ssone

    Member

  • Member
  • PipPipPip
  • 301 posts
welcome, anytime you need help you know where to find us :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP