Click to See Complete Forum and Search --> : banners Ads open New Page??


gavron1
10-09-2003, 12:59 AM
can someone tell me how to add to this script to get the banner ads to open in a new window?

<!-- ONE STEP TO INSTALL BANNER ADS:

1. Add the first code to the BODY of your HTML document -->

<!-- STEP ONE: Add the first code to the BODY of your HTML document -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="The World's Largest Online Bookstore, Amazon.com";
url="http://www.amazon.com";
alt="amazon.com";
banner="http://imageserv.imgis.com/images/Ad12669St1Sz1Sq1_Ban1.gif";
width="468";
height="60";
}
if (ad==2) {
txt="Palm III by 3Com, in stock!";
url="http://cybershop.com/";
alt="cybershop.com";
banner="http://imageserv.imgis.com/images/Ad13189St1Sz1Sq5_Ban10.gif";
width="468";
height="60";
}
if (ad==3) {
txt="Find it at GoTo.com";
url="http://www.goto.com";
alt="goto.com";
banner="http://imageserv.imgis.com/images/Ad13700St1Sz1Sq1_Ban1.gif";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</SCRIPT>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.44 KB -->

requestcode
10-09-2003, 07:18 AM
Change this line:
document.write('<a href=\"' + url + '\" target=\"_top\">');

To this:
document.write('<a href=\"' + url + '\" target=\"_new\">');

gavron1
10-09-2003, 07:25 AM
Perfect.... Thank you very much!

pyro
10-09-2003, 07:27 AM
_new? I think that should be _blank. http://www.w3.org/TR/REC-html40/types.html#h-6.16

requestcode
10-09-2003, 09:16 AM
I have used both _new and _blank and they both work the same. I have used them in different browsers with no problems.

pyro
10-09-2003, 10:04 AM
Generally, any target that the browser does not find (if used with frames)/understand will result in a new window. But, as far as I know, there is nothing that says they have to, so I'd use the correct version, which is target="_blank" (In transitional and frameset -- in strict, the target attribute has been depreciated).

requestcode
10-09-2003, 10:25 AM
Yep - your right. I did some test and found that I could name it anything and it would work. Not sure where I got the "_new" from. I have been using if for quite a while now. Must have tried it once and since it worked assumed it was alright. Thanks for the info. :)

pyro
10-09-2003, 06:13 PM
hehe... no problem... :)