Welcome to Geeklog, Anonymous Friday, April 19 2024 @ 02:21 pm EDT

Geeklog Forums

Random HTML


Status: offline

cypry

Forum User
Newbie
Registered: 06/06/05
Posts: 13
Location:UK
I want a block that can display a random webcam image from a list of webcams (some straight *.jpg images and some applets) along with an associated link and some text.

First I created a straight html page that contains a javascript to achieve what I want to do, which I have tested, and works. I then cut and pasted the javascript code int a normal block, but the block will not display any content.

Is there some kind of limitation on using Javascript in a block, or maybe there's already a plug in available to achieve what I need to do?


cypry.com - dubs, drops and descents......
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
are you using relative paths in your code? if the block appears on different pages, those paths will change and so to your ability to find your content. just a thought
 Quote

Status: offline

cypry

Forum User
Newbie
Registered: 06/06/05
Posts: 13
Location:UK
Nope - all of the webcams are on external sites, so I'm using full http addresses.
The code I'm using is as follows:
Text Formatted Code

<SCRIPT LANGUAGE="Javascript"><!--


function webcam() {
};

webcam = new webcam();
webcamno = 0;

// webcamArray
webcam[webcamno++] = "<a href='http://www.a1surf.com/surfcheck-fistralcam.html' target='_blank'>South Fistral</a><br><img src='http://www.a1surf.com/webcams/fistral-south.jpg' width='100' border='0' alt=''><br>"
webcam[webcamno++] = "<a href='http://www.a1surf.com/surfcheck-northfistralcam.html' target='_blank'>North Fistral</a><br><img src='http://www.a1surf.com/webcams/fistral-north.jpg' width='100' border='0' alt=''><br>"
webcam[webcamno++] = "<a href='http://www.a1surf.com/surfcheck-fistrallive.html' target='_blank'>Fistral Blu</a><br><APPLET NAME='push' Archive='pack.jar' CODEBASE='http://81.168.72.28' CODE='ServPush.class' width=100 height=75 mayscript=yes> </Applet><br>"
webcam[webcamno++] = "<a href='http://www.a1surf.com/surfcheck-newquay.html' target='_blank'>Newquay Bay</a><br><img src='http://www.newquaysurfcentre.com/images/newquay.jpg' width='100' border='0' alt=''><br>"
webcam[webcamno++] = "<a href='http://www.a1surf.com/surfcheck-western.html' target='_blank'>Great Western</a><br><img src='http://www.fistralsurf.com/webcam/surfcheck.jpg' width='100' border='0' alt=''><br>"

increment = Math.floor(Math.random() * webcamno);

document.write(webcam[increment]);

//--></SCRIPT>

 

cypry.com - dubs, drops and descents......
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
works for me as is in IE and Firefox... Giving it a try
 Quote

Status: offline

cypry

Forum User
Newbie
Registered: 06/06/05
Posts: 13
Location:UK
Me too - but when I put it in a block it won't work....?
cypry.com - dubs, drops and descents......
 Quote

mach

Anonymous
strange.. i put it in a block and have no troubles.
 Quote

Status: offline

cypry

Forum User
Newbie
Registered: 06/06/05
Posts: 13
Location:UK
I don't know either - now given up on the JavaScript and I've written a php function block instead....
Text Formatted Code
/**
*Custom Block for displaying Surf Cams
*/
function phpblock_surfcams ()
{
    $aHTML[0] = 'Put HTML code #1 here';
    $aHTML[1] = 'Put HTML code #2 here';
    $aHTML[2] = 'Put HTML code #3 here';
    $aHTML[3] = 'Put HTML code #4 here';
    $aHTML[4] = 'Put HTML code #5 here';
    $iUpper = sizeof($aHTML) - 1;
    $iLower = 0;

    $iIndex = rand($iLower, $iUpper);
    return $aHTML[$iIndex];
}


 


The above can be used for displaying any random html (edit where shown or add more $aHTML variables) in a block.
Simply add the above to your lib-custom.php and call the block phpblock_surfcams in your block manager.

Take a look at the Surfcams block on My Site Smile
cypry.com - dubs, drops and descents......
 Quote

All times are EDT. The time is now 02:21 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content