The Artima Developer Community
Sponsored Link

Java Answers Forum
how to open new window

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Pete

Posts: 1
Nickname: onward
Registered: Feb, 2003

how to open new window Posted: Feb 10, 2003 8:40 PM
Reply to this message Reply
Advertisement
OK, as you'll be able to tell, I know next to nothing about Java. That's why I'm here.
I'm using the code below to rotate banners on my site. I would like clicks on these banners to open in new windows. How would I do that? Thanks.



<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from JavaScript-Impaired Browsers
/* First, if you load fewer or more than 5 sponsors
into your rotator, change the "sponnr" variable
to the actual number of sponsor .gifs you plan to
load. */
number_of_sponsors=2;

var sctr=0;
var halt=0;
var isn=new Array();
for (j=0;j<number_of_sponsors;j++){
isn[j]=new Image();
}

/* The sponsor .gif names are loaded into the isn[x]
sponsor images array. You may load any number of
sponsor images (.gif or .jpg or both) into this
array. They must all be the same size, however.
Substitute your own .gif filenames for the ones
shown here. Note that the first .gif must appear
in the isn[0] array element. */
isn[0].src="http://www.website.com/banner1.gif";
isn[1].src="http://www.webs ite.com/banner2.gif";


/* Finally, replace the URL's below with those of
your sponsors IN THE SAME ORDER. */
var durl=new Array();
durl[0]="http://www.website.com/index1.html";
durl[1]="http://www.webs ite.com/index2.html";

/* This script is set to rotate every 10 seconds.
(5000=5 seconds, so 30000 would equal 30, etc)
You should change the number in the setTimeout()
call below for the number of seconds you wish. */
function rotateIt(){
if (halt!=1){
sctr++;
if (sctr>number_of_sponsors-1){
sctr=0;
}
document.sponsor.src=isn[sctr].src;
setTimeout("rotateIt()",15000);
}
}

/* This code will work just fine with or without
frames. However, if you are in frames and wish
to replicate the TARGET="_top" call to remove
frames, change the location.href call to:
parent.location.href=durl[sctr];
below. */
function doIt(){
halt=1;
location.href=durl[sctr];
}

function dispIt(){
parent.window.status=durl[sctr];
}
// End Hiding -->
</SCRIPT>

Topic: Review program/give input/help Previous Topic   Next Topic Topic: help to resolve errors

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use