|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
I have 4 photos, say they are called:
image1.jpg image2.jpg image3.jpg image4.jpg
Is there any way to have it so that in a custom island they appear at random (on each page view)?
In other pages we have that is done with some javascript I belive.
Anyone able to tell me how this would be done (and if it is easy what code to put in the island)?
Thank you very much
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
The randomizing Javascript should work in the custom island, if done properly, I would think....
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
OK thanks, good start. Anyone able to tell me what that would be Thanks!
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
Would something like this work? (ie. could I just put the below into the custom island?)
And would there be any compatibility problems with doing that?
=========================
<script type="text/javascript" language="javascript">
function randomads() {
var ads = new Array(); ads[0] = "image1.gif"; ads[1] = "image2.gif"; ads[2] = "image3.gif";
var adlinks = new Array(); adlinks[0] = "http://www.link1.com"; adlinks[1] = "http://www.link2.com"; adlinks[2] = "http://www.link3.com";
num=Math.floor(Math.random()*ads.length);
document.write("<a href=" +adlinks[num]+ " target=_blank> <img src=" +ads[num]+ " border=0></a>") }
</script>
thanks!
|
|
|
|
Joined: Feb 2007
Posts: 1,294 Likes: 2
Veteran
|
Veteran
Joined: Feb 2007
Posts: 1,294 Likes: 2 |
Looks like it should work.
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
You should keep document.write's on single lines, end each with a semi-colon, and escape the quotation marks. Something like this should work, but I'm a big groggy:
document.write('<a href=\"' +adlinks[num]+ '\" target=\"_blank\">');
document.write('<img src=\"' +ads[num]+ '\" border=\"0\"></a>');
If it doesn't work, View Source on my site, near the top you should see the BANNER ROTATION script I'm using -- modified, it should work for you...
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
Hi there
Can I just ask how come your code above is longer than the code in my post above?
thanks
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
Read what I said again...
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
I did, but it is unfortunately unclear to me why it has changed as it has.
Thanks.
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
Beyond this part? "You should keep document.write's on single lines, end each with a semi-colon, and escape the quotation marks." Not sure what I'm missing here, sorry...
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
Apparently yes, otherwise I would not be asking. My post had one "document.write". Yours has two. I do not understand why that is. Apologies for it not being clear, but that is why I am asking. Thanks.
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
I do not understand why that is. I already explained it. But if you don't wanna read and understand, then do it your way and hope for the best, sorry... I'm just here to help those willing to accept it...
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
OK I will just accept it I suppose without understanding any explanation that you say you posted.
Thanks anyway.
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
I'm sorry can I ask one more question, just to check before messing anything up!
Would that code all go in the island itself? (ie. not in the header insert)
Thanks
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
Give it a shot. You'll want to place it after the and before the
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
Sadly it didn't work. The header appeared but nothing else. I put this in the custom island:
<script type="text/javascript" language="javascript">
function randomads() {
var ads = new Array(); ads[0] = "http://www.domain.com/e/photo-galleries.jpg"; ads[1] = "http://www.domain.com/e/photo-galleries.jpg"; ads[2] = "http://www.domain.com/e/photo-galleries.jpg";
var adlinks = new Array(); adlinks[0] = "http://www.link1.com"; adlinks[1] = "http://www.link2.com"; adlinks[2] = "http://www.link3.com";
num=Math.floor(Math.random()*ads.length);
document.write('<a href=\"' +adlinks[num]+ '\" target=\"_blank\">'); document.write('<img src=\"' +ads[num]+ '\" border=\"0\"></a>');
}
</script>
Any ideas kind sirs? Thanks
|
|
|
|
Joined: Feb 2007
Posts: 1,294 Likes: 2
Veteran
|
Veteran
Joined: Feb 2007
Posts: 1,294 Likes: 2 |
Try this. The bold is what I think is missing in your code making it not work.
<script type="text/javascript" language="javascript">
function randomads() {
var ads = new Array(); ads[0] = "http://www.domain.com/e/photo-galleries.jpg"; ads[1] = "http://www.domain.com/e/photo-galleries.jpg"; ads[2] = "http://www.domain.com/e/photo-galleries.jpg";
var adlinks = new Array(); adlinks[0] = "http://www.link1.com"; adlinks[1] = "http://www.link2.com"; adlinks[2] = "http://www.link3.com";
var num=Math.floor(Math.random()*ads.length);
document.write('<a href=\"' +adlinks[num]+ '\" target=\"_blank\"><img src=\"' +ads[num]+ '\" border=\"0\"></a>');
}
</script>
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
you also ned to call the function itself from your portal box.. just declaring a function doesn't cause it to execute. somewhere you should do 'randomads();'
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
Thanks.
Where would I do that Sirdude?
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
Still beavering away at this but without much success. Pulls hair from head!!! Anyone able to assist. I actually now want this in the top header (rather than in a custom island) - don't know if that changes things or not.... Thank you!
|
|
|
|
Joined: Jan 2008
Posts: 81
journeyman
|
journeyman
Joined: Jan 2008
Posts: 81 |
This is what I'm using...
<head> <script type="text/javascript" language="JavaScript"> <!-- Copyright 2002 Bontrager Connection, LLC NumberOfImagesToRotate = 8; FirstPart = '<img src="http://****/images/cotm/cotm'; LastPart = '.jpg" height="356" width="245">';
function printImage() { var r = Math.ceil(Math.random() * NumberOfImagesToRotate); document.write(FirstPart + r + LastPart); } //--> </script> </head>
</html>
<body>
<table width="250" border="0" cellspacing="0" cellpadding="0" class="forumline"> <td width="250"> <p align="center"><b>Car Of The Month! </b> </p> <p align="center"><font size="2"><i>Click the image to view our Car Of The Month page.</i></font><center> <p></p> <p></p> <p align="center"> <a
href="http://****.com/boards/ubbthreads.php?ubb=showflat&Number=61844&g
onew=1#UNREAD"> <script type="text/javascript" language="JavaScript"><!-- printImage(); //--></script></a></td> </td> </table>
</body>
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
This is what I'm using...
<head> {etc} </head>
</html>
<body> {etc} </body> Seriously?? There should be no <head>, <body>, or <html> tags in custom islands or headers/footers -- they're already embedded into each page. And the </html> tag in the middle?? I'm surprised it even works... unless Threads is stripping those tags (they aren't rendering on your site, so maybe that's the case?)...
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
yah, that is not the way to do it
|
|
|
|
Joined: Feb 2007
Posts: 678
old hand
|
old hand
Joined: Feb 2007
Posts: 678 |
So what would the way of doing it be?
|
|
|
|
Bots
by Outdoorking - 04/13/2024 5:08 PM
|
|
|
0 members (),
850
guests, and
177
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
|
|