homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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

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

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

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)

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)

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() {

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