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:
See if you can follow the instructions for this code: Link It does provide optional randomised ordering.
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 ?
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):
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?
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.
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
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?
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:
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:
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?
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.
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:
Well its working but not working inside the block on my CMS as you can see on the bottom left hand side.
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:
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.
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">