homepage Welcome to WebmasterWorld Guest from 54.211.73.232
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Need to ammend a banner rotation script
So that links open in new window
litmania com

10+ Year Member



 
Msg#: 688 posted 12:59 am on May 18, 2001 (gmt 0)

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 :)


<SCRIPT language=JAVASCRIPT type=TEXT/JAVASCRIPT>
<!-- 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) {
thisAd++
if (thisAd == imgCt) {
thisAd = 0
}
document.adBanner.src=adImages[thisAd]
}
setTimeout("rotate()", 17 * 1000)
}
}

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

// End hiding script from old browsers -->
</SCRIPT>

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

src="/bla/ban/blabanukwholepic.jpg"
name=adBanner></A></div>

 

tedster

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



 
Msg#: 688 posted 5:16 am on May 19, 2001 (gmt 0)

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() {
window.open(adURL[thisAd],window2)
}
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.
Xoc

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 688 posted 5:40 am on May 19, 2001 (gmt 0)

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.

tedster

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



 
Msg#: 688 posted 11:48 pm on May 19, 2001 (gmt 0)

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() {
window.open(""+adURL[thisAd],"window2")
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved