Click to See Complete Forum and Search --> : Link Target Problems


snake_eyes097
07-08-2003, 08:45 PM
Hey all. On my site, I am trying to link to one of my favorite sites using a banner rotater to display a random banner. However, the image for the banner won't show up, even though it is the right target, and instead of taking you to www.homestarrunner.com, it tries to insert my URL first, so you get taken to http://www.geocities.com/arashikage097/"http://www.homestarrunner.com"

I'm really not good with Java yet, and I got this code from JavaScript Source Free Javascript. I tried changing some stuff, but couldn't get it working. The shortened code looks like this:

<!-- Begin
var how_many_ads = 5;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="Homestar Runner";
url="http://www.homestarrunner.com";
alt="Everybody! Everybody!";
banner="sbbanner0001.gif";
width="468";
height="60";
}
!!!!!!!!!THERE ARE FOUR OTHER BANNERS LISTED HERE, WRITTEN THE SAME WAY AS THE ONE ABOVE!!!!!!!!!!
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>

Sorry for the length of this message. If anyone can help me, I would really appreciate it.

Thanx,
Snake_Eyes097

Jonathan
07-08-2003, 10:00 PM
You will need 4 other banners for this to work... but here is the script.

<script language="JavaScript" type="text/javascript">
<!-- Begin
var how_many_ads = 5;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="Homestar Runner";
url="http://www.homestarrunner.com";
alt="Everybody! Everybody!";
banner="sbbanner0001.gif";
width="468";
height="60";
}
document.write('<center>');
document.write("<a href=\"" +url+ "\" target=\'_top\'>");
document.write("<img src=\"" + banner + "\" width=\"" +width+ "\"")
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</SCRIPT>

snake_eyes097
07-09-2003, 12:05 AM
Thank you Jonathan, but your solution didn't work. I still have the same problem. I can't figure it out, especially because when I just put a regular link in, even if it uses the same images, the it will work perfectly.

Anyone else?

Jonathan
07-09-2003, 10:07 AM
can you give me all the banner names? you might have to use an array... but I think the script I gave you works, because my IE6 worked.... well, if you can give me the scripts then I will see if I can make a banner rotater...

Jonathan
07-09-2003, 11:12 AM
Here.. the first script switches the banners on the fly... the second is reloaded...

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var mfBanners = [
['http://www.banner1-url-here.com', 'banner1.gif'],
['http://www.banner2-url-here.com', 'banner2.gif'],
['http://www.banner3-url-here.com', 'banner3.gif'],
['http://www.banner4-url-here.com', 'banner4.gif'],
['http://www.banner5-url-here.com', 'banner5.gif']
];
var mfIe = false;
if( document.all) {
mfIe = true;
}
var mfBannerIndex = 0;
function mfBannerChange() {
var htmlString = '<a target="_blank" href="'+mfBanners[mfBannerIndex][0]+'"> <img border="0" src="'+mfBanners[mfBannerIndex][1]+'"></a>';
if( mfIe) {
document.all.banner.innerHTML = htmlString;
}
else {
document.layers["banner"].document.open();
document.layers["banner"].document.write( htmlString);
document.layers["banner"].document.close();
}
if(mfBannerIndex < mfBanners.length - 1)
mfBannerIndex++;
else
mfBannerIndex = 0;
}
setInterval("mfBannerChange()", 300000);

/* The number above, "300000", is the amount of time you will give
your banners to rotate... this right now is 300 seconds. */

// End -->
</script>

</HEAD>


<!-- This goes into the body where you want it to appear -->
<div id="banner" style="position:absolute; top:300; left:171;"></div>










<!-- this is the second one -->

<HEAD>
<script language="JavaScript" type="text/javascript">
<!--
var banners = new Array(
'1.gif',
'2.gif',
'3.gif',
'4.gif',
'5.gif');
var linx = new Array(
'link1.html',
'link2.html',
'link3.html',
'link4.html',
'link5.html');
var old = 0;
var current = 0;

function fresh()
{
if (!document.images) return
while (current == old)
{
current = Math.floor(Math.random()*banners.length);
}
old = current;
document.images['banner'].src = banners[current];
setTimeout('fresh()',2000);
}

function sendPage()
{
location.href = linx[current];
}
</script>
</head>

<!-- This is the body -->

<BODY onLoad="fresh()">
<A HREF="javascript:sendPage()"><IMG
SRC="pix/mo_home.gif" NAME="banner"
WIDTH=80 HEIGHT=50 BORDER=0></A>

snake_eyes097
07-15-2003, 04:10 PM
Thanks Jonathan. That seemed to do it.


Ryan