...

View Full Version : Need two JavaScripts, maybe the search's over?



Geeks
01-10-2003, 08:30 PM
Hi, I'm trying to find these JavaScrips, but it's harder then I thought. :(
Appreciate it if anyone in here could point me thorward two JavaScrips wich does something like this:

Mask the url address (from http://www.telia.se/~4024024024 to just http://www.simple.org)

and

Reloading an image, just the image, not the hole page. (the script should allow me to determain patch to the image, and delay on when it should reload)

Anyone who answers this and by some mean can help me out, BIG thanks! :thumbsup:

Love ya :D

beetle
01-10-2003, 08:51 PM
Ok. Javascript won't be able to mask the URL like that. You'd need to customize Apache to achieve that.

About your images reloading? Hmmm, this should work...
function reloadImage( time, imgId )
{
setTimeout( "document.images[imgId].src = document.images[imgId].src", time );
}Note that in javascript the time parameter is in milliseconds, so a 3 second delay would be 3000

Geeks
01-10-2003, 09:29 PM
I wrote this



<SCRIPT LANGUAGE="JavaScript">

function reloadImage( 5000, http://217.215.80.210:80/cam.jpg )
{
setTimeout(

"document.images[http://217.215.80.210:80/cam.jpg].src =

document.images[http://217.215.80.210:80/cam.jpg].src", 5000 );
}
</SCRIPT>


My image's located over at http://217.215.80.210:80/cam.jpg

...nothing showed, I'm pretty sure I did something wrong.

Anyone correct this for me, caus I don't know how too.

beetle
01-10-2003, 09:38 PM
You've got the wrong idea.
<html>
<head>
<script type="text/javascript">
function reloadImage( time, imgId )
{
setInterval( "document.images[imgId].src = document.images[imgId].src", time );
}
</script>
</head>

<body onload="reloadImage( 5000, 'camPic' );">

<img src="http://217.215.80.210:80/cam.jpg" id="camPic">

</body>
</html>This will refresh the image EVERY five seconds.

Geeks
01-10-2003, 10:00 PM
So far so good.
The image appears.

But only once.

The page tries to reload after 5 secounds, but then, down there on the IE status bar, it says something like "Error on page" and the same picture's shown.

It'll reload tho normal when I push the regulair reload-button.

Seems good this far, now, on how to fix that... does it work ok for you? You can see my test-page over at here (http://home.no/philipshemsida/TEST.html) and tell me how it went.

Thanks dude for your help by the way, very appreciated. :thumbsup:

beetle
01-10-2003, 10:08 PM
Sorry, I forgot those intervals need global variables...
function reloadImage( time, imgId )
{
window.myImage = document.images[imgId];
setInterval( "myImage.src = myImage.src", time );
}

Geeks
01-10-2003, 10:50 PM
Seems to be running fine now... I'll just implant it into my homepage and we'll see soon...

Geeks
01-11-2003, 12:33 AM
The code worked perfectly.

Thank you beetle very much, you've been to great help.

The JavaScript's updating my webcam pictures, and without reloading the hole page, exactly as I wanted it... sure rocks! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum