View Full Version : Rotating Weblinks JavaScript Code
SKULL
Apr 6th 2007, 10:16 am
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>
Logic Ali
Apr 6th 2007, 11:47 am
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
See if you can follow the instructions for this code: Link (http://www.hotspot.freeserve.co.uk/scripterlative?rbanner) It does provide optional randomised ordering.
SKULL
Apr 6th 2007, 7:13 pm
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 ?
giraph
Apr 6th 2007, 8:04 pm
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>
Logic Ali
Apr 7th 2007, 2:38 am
When i click on that link all i get is "Error 500 (Internal Server Error) 'www.hotspot.freeserve.co.uk' could not be found."
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?
SKULL
Apr 7th 2007, 9:30 am
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>
That code is not working , i already tryed that one, its the same one as i posted in the first thread.
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?
I wont it to desply random Weblinks.
giraph
Apr 7th 2007, 3:05 pm
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
SKULL
Apr 7th 2007, 4:29 pm
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>
?>
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>";
?>
Any ideas?
giraph
Apr 7th 2007, 9:02 pm
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
?>
SKULL
Apr 7th 2007, 9:20 pm
Thats got it thank you giraph!
SKULL
Apr 8th 2007, 1:03 pm
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>" ;
?>
giraph
Apr 8th 2007, 4:57 pm
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?
SKULL
Apr 8th 2007, 5:22 pm
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.
giraph
Apr 8th 2007, 8:28 pm
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>";
?>
SKULL
Apr 8th 2007, 8:50 pm
Well its working but not working inside the block on my CMS as you can see on the bottom left hand side.
giraph
Apr 8th 2007, 9:12 pm
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>';
?>
SKULL
Apr 8th 2007, 9:20 pm
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.
giraph
Apr 8th 2007, 9:27 pm
What website are you talking about?
SKULL
Apr 8th 2007, 9:32 pm
What website are you talking about?
www.allnukestuff.com on the bottom left hand side.
giraph
Apr 8th 2007, 9:33 pm
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>';
to display the links, don't put
echo $contents;
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">
SKULL
Apr 8th 2007, 9:54 pm
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>';
to display the links, don't put
echo $contents;
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">
so how should the hole code look as im confused with the last reply you posted :confused:
giraph
Apr 8th 2007, 9:56 pm
Inside the box you should have:
<?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>';
?>
It seems right now you have
echo $contents;
which isnt right, but I don't know because I can't see your code.
SKULL
Apr 8th 2007, 10:04 pm
Here is the code i have in the box at the moment that is not working
<?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>';
?>
giraph
Apr 8th 2007, 10:06 pm
Well it's apparently not in the box, I can't help you much further without more information, sorry.
SKULL
Apr 9th 2007, 9:03 pm
Well it's apparently not in the box, I can't help you much further without more information, sorry.
Ok well thanks for your help giraph and thanks for your time it was helpful.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.