How do i rotate this banner script

7 replies
This is my rotating code
<div id="adspace">
<script language="JavaScript" type="text/javascript">
ads = new Array(3);
ads[0] = "<a href='http://instantsplash.com/signup.php?ref=6731y5exy36' rel='nofollow' target='_blank'>" +
"<img src='http://instantsplash.com/a/images/website/IS-125x125.png' border='0' height='121px' width='121px'/></a>";

ads[1] = "<a href='http://instantsplash.com/signup.php?ref=6731y5exy36' rel='nofollow' target='_blank'>" +
"<img src='http://instantsplash.com/a/images/website/IS-125x125.png' border='0' height='121px' width='121px'/></a>";

ads[2] = "<a href='http://refban.com/70024' rel='nofollow' target='_blank'>" +
"<img src='http://x.refban.com/125x125_1.gif' border='0' height='121px' width='121px'/></a>";

index = Math.floor(Math.random() * ads.length);
document.write(ads[index]);

</div>


It rotates 3 images. This is what i am trying to replace each image with

<script type="text/javascript" src="http://adhitzads.com/701087"></script>



The Problem
- the image attached to the script is unavailable by its self, it only comes with the script. I have tried replacing the link and img src code with the source provided in the script but it just doesn't work.

I know that their is a way to rotate that script within the code rotation i provided. Anyone care to help?
#banner #rotate #script
  • Profile picture of the author Fanzi
    Code:
    <!DOCTYPE html>
    <html lang="en"><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <head><title>Test</title></head>
    <body onLoad="rotate()">
    This is my rotating code
    <div id="adspace">
    <script language="JavaScript" type="text/javascript">
    function rotate(){
    
    ads = new Array(3);
    ads[0] = "<a href='http://instantsplash.com/signup.php?ref=6731y5exy36' rel='nofollow' rel="nofollow" target='_blank'>" +
    "<img src='http://instantsplash.com/a/images/website/IS-125x125.png' border='0' height='121px' width='121px'/></a>";
    
    ads[1] = "<a href='http://instantsplash.com/signup.php?ref=6731y5exy36' rel='nofollow' rel="nofollow" target='_blank'>" +
    "<img src='http://instantsplash.com/a/images/website/IS-125x125.png' border='0' height='121px' width='121px'/></a>";
    
    ads[2] = "<a href='http://refban.com/70024' rel='nofollow' rel="nofollow" target='_blank'>" +
    "<img src='http://x.refban.com/125x125_1.gif' border='0' height='121px' width='121px'/></a>";
    
    index = Math.floor(Math.random() * ads.length);
    alert(index);
    document.write(ads[index]); 
    }
    </script>
    </div>
    </body>
    </html>
    {{ DiscussionBoard.errors[8991737].message }}
    • Profile picture of the author OfficerIM
      Originally Posted by Fanzi View Post

      Code:
      <!DOCTYPE html>
      <html lang="en"><head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <head><title>Test</title></head>
      <body onLoad="rotate()">
      This is my rotating code
      <div id="adspace">
      <script language="JavaScript" type="text/javascript">
      function rotate(){
      
      ads = new Array(3);
      ads[0] = "<a href='http://instantsplash.com/signup.php?ref=6731y5exy36' rel='nofollow' rel="nofollow" target='_blank'>" +
      "<img src='http://instantsplash.com/a/images/website/IS-125x125.png' border='0' height='121px' width='121px'/></a>";
      
      ads[1] = "<a href='http://instantsplash.com/signup.php?ref=6731y5exy36' rel='nofollow' rel="nofollow" target='_blank'>" +
      "<img src='http://instantsplash.com/a/images/website/IS-125x125.png' border='0' height='121px' width='121px'/></a>";
      
      ads[2] = "<a href='http://refban.com/70024' rel='nofollow' rel="nofollow" target='_blank'>" +
      "<img src='http://x.refban.com/125x125_1.gif' border='0' height='121px' width='121px'/></a>";
      
      index = Math.floor(Math.random() * ads.length);
      alert(index);
      document.write(ads[index]); 
      }
      </script>
      </div>
      </body>
      </html>



      Where did you place the script i want to rotate, i cant find it?
      {{ DiscussionBoard.errors[8998718].message }}
  • Profile picture of the author MYFREEIM
    You really can't do what your asking without writing an extensive JS code that will append that ad script to your rotator script. And adding the src URL that's contained within that ad script doesn't work because that is not the URL to where the image is located, it's the URL to where the script its located. That script basically connects your affiliate id and the image and makes them one item.

    You should to go back to your affiliate site and see if they offer separate links for images and affiliate ids. Sorry..

    Or, can you run that ad script and when the image comes up, copy and save as? This way you can upload to your image folder on your server and use that URL source...
    Signature
    IM GUIDE Developer
    {{ DiscussionBoard.errors[8999004].message }}
    • Profile picture of the author OfficerIM
      Originally Posted by MYFREEIM View Post

      You really can't do what your asking without writing an extensive JS code that will append that ad script to your rotator script. And adding the src URL that's contained within that ad script doesn't work because that is not the URL to where the image is located, it's the URL to where the script its located. That script basically connects your affiliate id and the image and makes them one item.

      You should to go back to your affiliate site and see if they offer separate links for images and affiliate ids. Sorry..

      Or, can you run that ad script and when the image comes up, copy and save as? This way you can upload to your image folder on your server and use that URL source...
      I figured, thanks.
      {{ DiscussionBoard.errors[9007003].message }}
  • Profile picture of the author David Beroff
    Rather than trying to get the JavaScript to conditionally include another JavaScript file, why not just do your banner rotation in PHP, and then that code can output either the a/img or script as needed?
    Signature
    Put MY voice on YOUR video: AwesomeAmericanAudio.com
    {{ DiscussionBoard.errors[8999800].message }}
    • Profile picture of the author OfficerIM
      Originally Posted by David Beroff View Post

      Rather than trying to get the JavaScript to conditionally include another JavaScript file, why not just do your banner rotation in PHP, and then that code can output either the a/img or script as needed?
      I don't know PHP
      {{ DiscussionBoard.errors[9007004].message }}
      • Profile picture of the author David Beroff
        Originally Posted by OfficerIM View Post

        I don't know PHP
        Well, here's a great opportunity to learn, then! What you're trying to do would be very similar in PHP.
        Signature
        Put MY voice on YOUR video: AwesomeAmericanAudio.com
        {{ DiscussionBoard.errors[9007258].message }}

Trending Topics