Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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