1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rotating Weblinks JavaScript Code

Discussion in 'JavaScript' started by SKULL, Apr 6, 2007.

  1. #1
    Hi i am trying to make a rotating JavaScript code i can not seem to find one to work or edit one to work here is what i have so far but its not working can anyone give me a working rotating weblinks code please

    
    <SCRIPT LANGUAGE="Javascript"><!-- 
    function banner() { 
    }; 
    banner = new banner(); 
    number = 0; 
    // bannerArray 
    banner[number++] = "<a href="http://www.url-link.com">CLICK HERE</a>"
    banner[number++] = "<a href="http://www.url-link.com">CLICK HERE 2</a>"
    banner[number++] = "<a href="http://www.url-link.com">CLICK HERE 3</a>"
    banner[number++] = "<a href="http://www.url-link.com">CLICK HERE 4</a>"
    
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(banner[increment]); 
    //--></SCRIPT>
    PHP:
     
    SKULL, Apr 6, 2007 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    See if you can follow the instructions for this code: Link It does provide optional randomised ordering.
     
    Logic Ali, Apr 6, 2007 IP
  3. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #3
    When i click on that link all i get is "Error 500 (Internal Server Error) 'www.hotspot.freeserve.co.uk' could not be found."

    Can anyone else help ?
     
    SKULL, Apr 6, 2007 IP
  4. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here you go:

    
    <SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 2</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 3</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 4</a>";
    
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT> 
    
    Code (markup):
     
    giraph, Apr 6, 2007 IP
  5. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #5
    It could only have been a temporary problem. Try it again.
    Could you clarify exactly what it is that you want; are you trying eventually to display graphical banners, or just a link with a random URL?
     
    Logic Ali, Apr 7, 2007 IP
  6. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #6
    That code is not working , i already tryed that one, its the same one as i posted in the first thread.

    I wont it to desply random Weblinks.
     
    SKULL, Apr 7, 2007 IP
  7. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The code i posted is NOT the same as what you posted in the first post. Please review it and see where I made changes; it DOES work. You can see it live on:

    http://giraph.com/test.php
     
    giraph, Apr 7, 2007 IP
  8. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #8
    Yes sorry it dos work but any chance i can get this to work with php i would like to ad this as a php block on a CMS site.

    I tryed this but it did not work..

    <?php
    <center><SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 2</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 3</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 4</a>";
    
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT><center>
    ?>
    PHP:
    And then i tryed this and this did not work..

    <?php
    if (eregi("block-Rotating-Links.php",$PHP_SELF)) {
        Header("Location: index.php");
        die();
    }
    $content  =  "<SCRIPT LANGUAGE=\"Javascript\"><!-- ";
    $content  .= "var Banner = new Array() ";
    $content  .= "number = 0";
    $content  .= "// bannerArray ";
    $content  .= "Banner[number++] = \"<a href=\"http://www.url-link.com\">CLICK HERE</a>";
    $content  .= "Banner[number++] = \"<a href=\"http://www.url-link.com\">CLICK HERE 2</a>";
    $content  .= "Banner[number++] = \"<a href=\"http://www.url-link.com\">CLICK HERE 3</a>";
    $content  .= "Banner[number++] = \"<a href=\"http://www.url-link.com\">CLICK HERE 4</a>";
    $content  .= "";
    $content  .= "";
    $content  .= "increment = Math.floor(Math.random() * number)";
    $content  .= "";
    $content  .= "document.write(Banner[increment])";
    $content  .= "//--></SCRIPT>";
    ?>
    PHP:
    Any ideas?
     
    SKULL, Apr 7, 2007 IP
  9. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #9
    haha you're making it too complicated =P

    
    <?php
    $content  =  '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 2</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 3</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 4</a>";
    
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT>';
    
    //echo $content; or whatever
    
    ?>
    
    PHP:
     
    giraph, Apr 7, 2007 IP
    SKULL likes this.
  10. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #10
    Thats got it thank you giraph!
     
    SKULL, Apr 7, 2007 IP
  11. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #11
    Say i wont to add 5 rotating links and a url at the bottom to go to url , i tryed using this code but its not working am i missing some code out?

    <?php
    $content  =  '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url.com\">link1</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link2</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link3</a>";
    Banner[number++] = "<a href=\"http://www.url.comt\">link4</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link5</a>";
    increment = Math.floor(Math.random() * number); 
    document.write(Banner[increment]); 
    //--></SCRIPT>';//
    $content  =  '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url.com\">link1</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link2</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link3</a>";
    Banner[number++] = "<a href=\"http://www.url.comt\">link4</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link5</a>";
    increment = Math.floor(Math.random() * number); 
    document.write(Banner[increment]); 
    //--></SCRIPT>';//
    $content  =  '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url.com\">link1</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link2</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link3</a>";
    Banner[number++] = "<a href=\"http://www.url.comt\">link4</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link5</a>";
    increment = Math.floor(Math.random() * number); 
    document.write(Banner[increment]); 
    //--></SCRIPT>';//
    $content  =  '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url.com\">link1</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link2</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link3</a>";
    Banner[number++] = "<a href=\"http://www.url.comt\">link4</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link5</a>";
    increment = Math.floor(Math.random() * number); 
    document.write(Banner[increment]); 
    //--></SCRIPT>';//
    $content  =  '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url.com\">link1</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link2</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link3</a>";
    Banner[number++] = "<a href=\"http://www.url.comt\">link4</a>";
    Banner[number++] = "<a href=\"http://www.url.com\">link5</a>";
    increment = Math.floor(Math.random() * number); 
    document.write(Banner[increment]); 
    //--></SCRIPT>';//
    $content = "<br>;
    $content = "<a href=\"http://www.allnukestuff.com/modules.php?name=Text_Links\">View All TextLinks</a>" ;
    ?>
    PHP:
     
    SKULL, Apr 8, 2007 IP
  12. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Can you clarify what you want? You want 5 random links at a time? Like:

    Link1
    Link5
    Link8
    Link12
    Link15
    View All TextLinks

    Like that?
     
    giraph, Apr 8, 2007 IP
  13. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #13

    I need 5 textlinks rotating 5 links at a time , then a url at bottom saying view all textlinks , if you get what i mean.

    Example

    1st rotating links rotating 5 links
    2nd rotating links rotating 5 links
    3rd rotating links rotating 5 links
    4th rotating links rotating 5 links
    5th rotating links rotating 5 links
    url to all textlinks page

    I hope you understand what i mean.

    Thanks for your help on this.
     
    SKULL, Apr 8, 2007 IP
  14. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Well... this isn't exactly the best way to do this haha, but this should work. I'm not a big fan of php honestly.

    
    <?php
    $content = array();
    
    //Links 1
    
    array_push($content, '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 2</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 3</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 4</a>";
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT>');
    
    
    //Links 2
    
    array_push($content, '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 6</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 7</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 8</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 9</a>";
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT>');
    
    
    
    //Links 3
    
    array_push($content, '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 10</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 11</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 12</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 13</a>";
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT>');
    
    
    //Links 4
    
    array_push($content, '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 14</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 15</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 16</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 17</a>";
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT>');
    
    
    
    //Links 5
    
    array_push($content, '<SCRIPT LANGUAGE="Javascript"><!-- 
    var Banner = new Array(); 
    number = 0; 
    // bannerArray 
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 18</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 19</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 20</a>";
    Banner[number++] = "<a href=\"http://www.url-link.com\">CLICK HERE 21</a>";
    
    increment = Math.floor(Math.random() * number); 
    
    document.write(Banner[increment]); 
    //--></SCRIPT>');
    
    echo "$content[0]<br>$content[1]<br>$content[2]<br>$content[3]<br>$content[4]<br><a href=\"http://www.google.com\">View more links</a>";
    
    ?>
    
    PHP:
     
    giraph, Apr 8, 2007 IP
  15. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #15
    Well its working but not working inside the block on my CMS as you can see on the bottom left hand side.
     
    SKULL, Apr 8, 2007 IP
  16. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Well you really don't need javascript, so try this.

    
    <?php
    $content = array();
    
    //Links go here
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 1</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 2</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 3</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 4</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 5</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 6</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 7</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 8</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 9</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 10</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 11</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 12</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 13</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 14</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 15</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 16</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 17</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 18</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 19</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 20</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 21</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 22</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 23</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 24</a>');
    array_push($content, '<a href="http://www.url-link.com">CLICK HERE 25</a>');
    
    //25 links loaded.
    
    for($i = 0; $i < 5; $i++)
    {
    	echo $content[rand($i * 5, $i * 5 + 4)];
    	echo "<br>";
    }
    echo '<a href="http://www.google.com">More Links</a>';
    
    ?>
    
    PHP:
     
    giraph, Apr 8, 2007 IP
  17. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #17
    Still getting same issue wont show in the TextLinks block on left hand side.

    i have a feeling its the Array_push code, as the block says array inside it but dont show the links only shows them out side the block.
     
    SKULL, Apr 8, 2007 IP
  18. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #18
    What website are you talking about?
     
    giraph, Apr 8, 2007 IP
  19. SKULL

    SKULL Prominent Member

    Messages:
    5,301
    Likes Received:
    303
    Best Answers:
    0
    Trophy Points:
    350
    Digital Goods:
    1
    #19
    www.allnukestuff.com on the bottom left hand side.
     
    SKULL, Apr 8, 2007 IP
  20. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Make sure you're using
    
    for($i = 0; $i < 5; $i++)
    {
        echo $content[rand($i * 5, $i * 5 + 4)];
        echo "<br>";    
    }
    echo '<a href="http://www.google.com">More Links</a>';
    
    PHP:
    to display the links, don't put

    
    echo $contents;
    
    PHP:
    in the box.

    --

    Also I made a mistake in my code, i had <a href=\"http://thesite.com\">

    Should have been <a href="http://thesite.com">
     
    giraph, Apr 8, 2007 IP