Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2009
    Location
    vegas baby!
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question help get links to open in a new window, and timming issiue

    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:

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

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

    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...

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    Code:
    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
    Code:
    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
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    katai_kennels (01-22-2009)

  • #3
    New Coder
    Join Date
    Jan 2009
    Location
    vegas baby!
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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....!

  • #4
    New Coder
    Join Date
    Jan 2009
    Location
    vegas baby!
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Try
    Code:
    var currentAd1 = Math.round(Math.random() * 2 );
    instead of
    Code:
    var currentAd1 = 0;
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    New Coder
    Join Date
    Jan 2009
    Location
    vegas baby!
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts

    gave it a shot

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •