Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Need to ammend a banner rotation script

So that links open in new window

12:59 am on May 18, 2001 (gmt 0)

10+ Year Member

Is this the right forum to ask Javascript questions??

How do I ammend the following banner rotation code so that the links open in a new window please? Thank you very much :)

<!-- Hide script from old browsers

adImages = new Array("http://www.qksrv.net/image-734283-1205205","/bla/ban/blabanukalig.gif","/whs/cdp/ban/cdpbanlikemusic.gif")
adURL = new Array("http://www.qksrv.net/click-734283-1205205","http://www.UKHotMovies.com/shopping","http://WHSmithMusic.cjb.net")
thisAd = 0
imgCt = adImages.length

function rotate() {
if (document.images) {
if (document.adBanner.complete) {
if (thisAd == imgCt) {
thisAd = 0
setTimeout("rotate()", 17 * 1000)

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

// End hiding script from old browsers -->

<A href="javascript:newLocation()"><IMG


5:16 am on May 19, 2001 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

The following function definition is where you need to make the change.
function newLocation() {
document.location.href = "" + adURL[thisAd]
Instead of just resetting document.location.href, the function needs to open a new window for the URL, something like this:
function newLocation() {
I'm not quite sure what those double quotes with no content are all about in the original code. Hope this gives you a place to start testing something new, anyway.


5:40 am on May 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

The double quotes could be used in other contexts to force the expression to turn into a string. If you did "6" + 7, how is that supposed to be evaluated? 13 or "67"? I don't think it has any impact in this procedure, but by concatinating a string that doesn't evaluate to a number onto something, it should cause the entire expression to become a string.
11:48 pm on May 19, 2001 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Good observation, Xoc. Forcing the variable to be a string makes sense. But, as you also said, it is unlikely that this is needed in this case.

Maybe this is simply a remnant of a different script that was modified for this purpose. But it sure won't hurt anything to leave that pair of double quotes in there, just to be sure.

Speaking of double quotes, I believe I forgot a pair of them -- the name of the new window, "window2", needs them. So now the code might look like this:

function newLocation() {

Featured Threads

Hot Threads This Week

Hot Threads This Month