Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Junior Member
    Join Date
    Jun 2007
    Location
    Miami, Fl
    Posts
    23
    Member #
    15401
    I'm using the following script to rotate pictures and banners on my site, and it works perfectly. However, I'm also using it to randomly display links for sponsors at the bottom of the homepage, but i need to know how to make the banners linkable to their respective sites in a new window. Code is as follows...

    Code:
    <!-- Begin rotating ad code -->
          <script type="text/javascript"><!-- 
    function image() { 
    }; 
    image = new image(); 
    number = 0; 
    // imageArray 
    image[number++] = "<img src='images/banner_phil copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_shant copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_shant2 copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_tandem copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_ryan copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_shant3 copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_chelsea copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_shant4 copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    image[number++] = "<img src='images/banner_jose copy.jpg' style='display: block;' border='0' alt='Aero K'>"
    // Carry on adding images - as many as you want
    increment = Math.floor(Math.random() * number); 
    document.write(image[increment]); 
    //-->
      </script>
          <!-- End rotating ad code -->
    I've tried adding in
    Code:
    <a href="domain"><img tag></a>
    , but it doesnt work, and I have no idea how to write javascript. Please help!

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    image[number++] = "<a href='domain'><img src='images/banner_jose copy.jpg' style='display: block;' border='0' alt='Aero K'></a>"

    not sure, but you may need to mark out the / in /a
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Junior Member
    Join Date
    Jun 2007
    Location
    Miami, Fl
    Posts
    23
    Member #
    15401
    ^tried it, not working

    think i figured out my problem, but it doesnt help. javascript reads the two // in the domain name as a command to start a comment, so once i enter http://, it thinks anything after that is a comment. :-( how else can i do this? any other rotating image scripts i can use that let you click through to a new window?

  5. #4
    Senior Member Ferro's Avatar
    Join Date
    Oct 2006
    Location
    UK
    Posts
    386
    Member #
    14204
    Liked
    5 times
    Quote Originally Posted by whiterabbit7500
    ^tried it, not working

    think i figured out my problem, but it doesnt help. javascript reads the two // in the domain name as a command to start a comment, so once i enter http://, it thinks anything after that is a comment. :-( how else can i do this? any other rotating image scripts i can use that let you click through to a new window?
    could you enter them as ascii code?

  6. #5
    Junior Member
    Join Date
    Jun 2007
    Location
    Miami, Fl
    Posts
    23
    Member #
    15401
    i'm a n00b man...i would have no idea how t code it for that. if anyone can make that code work, i'll be VERY appreciative!

  7. #6
    Junior Member
    Join Date
    Jun 2007
    Location
    Miami, Fl
    Posts
    23
    Member #
    15401
    this might help. found this script online, that calls for this section...

    Code:
    window.onload = initBannerLink;
    
    var adImages = new Array("images/sponsers/RW_black.jpg","images/sponsers/SW_chrome.jpg");
    var adURL = new Array("revvwear.com","sponsoredwhips.com");
    var thisAd = 0;
    
    function rotate() {
        thisAd++;
        if (thisAd == adImages.length) {
            thisAd = 0;
        }
        document.getElementById("adBanner").src = adImages[thisAd];
    
        setTimeout("rotate()", 3 * 1000);
    }
    
    function newLocation() {
        document.location.href = "http://www." + adURL[thisAd];
        return false;
    }
    
    function initBannerLink() {
        if (document.getElementById("adBanner").parentNode.tagName == "A") {
            document.getElementById("adBanner").parentNode.onclick = newLocation;
        }
        
        rotate();
    }
    to be written in a .js file, and called upon by...

    Code:
    <script src="js/script1.js" language="javascript" type="text/javascript"></script>
    tried it...didnt work. any ideas?

  8. #7
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    don't put http:// should work fine w/ just www.domain.com
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  9. #8
    Junior Member
    Join Date
    Jun 2007
    Location
    Miami, Fl
    Posts
    23
    Member #
    15401
    i'll try it out when i get home. how do i set the target: "_blank" in java? or would it be the same as HTML?

  10. #9
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    you simply output them in the link as usual. I'ts javascript btw.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  11. #10
    Junior Member
    Join Date
    Jun 2007
    Location
    Miami, Fl
    Posts
    23
    Member #
    15401
    ok, tried this...

    Code:
    <!-- Begin rotating ad code -->
                <script type="text/javascript"><!-- 
    function image() { 
    }; 
    image = new image(); 
    number = 0; 
    // imageArray 
    image[number++] = "<a href='www.revvwear.com' target='_blank'><img src='images/sponsers/RW_black.jpg' style='display: block;'  border='0' alt='Aero K'></a>"
    image[number++] = "<a href='www.sponsoredwhips.com' target='_blank'><img src='images/sponsers/SW_chrome.jpg' style='display: block;' border='0' alt='Aero K'></a>"
    // Carry on adding images - as many as you want
    increment = Math.floor(Math.random() * number); 
    document.write(image[increment]); 
    //-->
                </script>
              </p>
              <p align="center" class="style1">
                <!-- End rotating ad code -->
    it made it link, but now it outputs a bunch of the code at the end of the script before, and after the banner. anyone know why?


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:10 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com