...

View Full Version : help get links to open in a new window, and timming issiue



katai_kennels
01-22-2009, 05:57 PM
Hello,

Super newbie here, lol.
this is probably a retard level question but I'm hoping to get some help here.

I'm adding a rotating banner to a VB fourm, so far it rotates and is "clickable" (if that's a word)

the problem is, I cant get it to open in a new window and the ad rotates too slow.

here is the code I'm working with:


<script type="text/javascript">
var imgs1 = new Array("http://i41.photobucket.com/albums/e299/kataikennels123456789/xllogo.jpg","http://i41.photobucket.com/albums/e299/kataikennels123456789/MAJORLEAGE.jpg","http://i41.photobucket.com/albums/e299/kataikennels123456789/GGPITS.jpg");
var lnks1 = new Array("http://www.xplicitlook.com/","http://www.majorleaguepitbulls.com/","http://www.gargoylepits.com/");
var alt1 = new Array();
var currentAd1 = 0;
var imgCt1 = 3;
function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
currentAd1++;
}
window.setInterval("cycle1()",10000);
</script>
<a href=""http://www.xplicitlook.com/"" id="adLink1" target="_top">
<img src="http://i41.photobucket.com/albums/e299/kataikennels123456789/xllogo.jpg" id="adBanner1" border="0" width="127" height="127"></a>

I was able to find this info:


<script language="JavaScript">
<!--
function makenew()
{window.open("testwindow4.htm","blank","toolbar=no,width=250,height=250")}
-->
</script>

But I'm not sure if that is the right code or where to put it?

also not sure how to set the rotation time :confused:

Any help would be greatly appreciated, let me know if this post is in the wrong spot or i left out needed info. I read throught the rules, if i don't post this right feel free to tell me to go play in the freeway... lol...

_Aerospace_Eng_
01-22-2009, 06:23 PM
Change this

function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
currentAd1++;
}
window.setInterval("cycle1()",10000);

to this

function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').setAttribute('href',lnks1[currentAd1]);
document.getElementById('adLink1').setAttribute('target','_blank');
currentAd1++;
}
window.setInterval("cycle1()",1000); // adjust this for the timing. 1000 = 1 second

katai_kennels
01-22-2009, 06:35 PM
wow... know I know that was probably the eaisest thing you did all day... but It helped out in a big way... It worked great, thank you....!

katai_kennels
01-22-2009, 06:42 PM
I did leave out one question,
every time I hit refresh, the first banner (in the rotation)
always starts first (obviously)

Is there away to add to the code so when clicking threw the VB forum (multiple pages) it didn't always start with the first banner? I'm thinking if people aren't staying on a page that long they will not even see the 2nd, 3rd, 4th banners.

abduraooft
01-23-2009, 07:05 AM
Try

var currentAd1 = Math.round(Math.random() * 2 ); instead of


var currentAd1 = 0;

katai_kennels
01-24-2009, 06:21 PM
I made the change, everything seems to be working the same way it was before. everytime I go to a new page it still starts with 1 and cycles threw.

could it be that there are not enough images? maybe if i had more than three it would work?

i'm going to be adding a few more images to it, I'll post if i see a change with more images.

thanks for yout time and help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum