Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Sweden
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need two JavaScripts, maybe the search's over?

    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!

    Love ya

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Code:
    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
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Sweden
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wrote this

    Code:
    <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.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You've got the wrong idea.
    Code:
    <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.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Sweden
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    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 and tell me how it went.

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

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I forgot those intervals need global variables...
    Code:
    function reloadImage( time, imgId )
    {
        window.myImage = document.images[imgId];
        setInterval( "myImage.src = myImage.src", time );
    }
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Sweden
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Seems to be running fine now... I'll just implant it into my homepage and we'll see soon...

  • #8
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Sweden
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •