The Geek Culture Forums
Ask a Geek! Javascript Reload Help
|
UBBFriend: Email This Page to Someone! | next newest topic | next oldest topic |
Author | Topic: Javascript Reload Help |
Tyler Durden Super Geek Posts: 212 |
posted August 19, 2002 00:53
trying to make it so the page will reload in 5, 10, 15 second intervals as specified by the user... for webcam use obviously... am I overlooking something? I haven't touched javascript in a while and I left my book 200 miles away edit: I want this because I change the interval on the image depending on what's on camera... if its on me, the update should be 5 seconds or whatever... if I'm gone and I'm watching stuff outside my window, it should be higher... code:<html> -- Jack's Puzzled Mind ------------------ IP: Logged |
uilleann Highlie Posts: 721 |
posted August 19, 2002 04:11
setTimeout() works by storing the instruction provided by the first argument, and executing it after the amount of time in the second argument elapses. The problem in your code is that the variable time is an actual argument of the function, which does not exist outside of the function and is not known to the timer system. The solution is to make the value of the time variable a part of the argument string, thus: Further information on setTimeout can be found on WebMonkey. I'm a bit suprised that the JavaScript keeps running even through a page reload. Furthermore, another issue that you might hit is image caching, where the image will refuse to reload at all thanks to the browser caching it. To force the image to always reload, try: code: Alas, with slower connections, the image will spend more time in the reloading state than actually visible (it will keep being cleared as the new one starts to load). With some help from http://www.nickshanks.com/cams/ , you could try this manically weird code which, I hope, will leave the old image on the screen until the new one is downloaded, so that you actually get a chance to see each one, without having to resort to long refresh times just to see the image. Again, the image needs a name="camImage" property. Nick Shanks' site's actual code allows the image to be updated as fast as is possible with the current connection; neat code. code: Give us a shout if it doesn't work :) (I don't have an updating cam to hand to test it on) - uilleann's manic coding madness IP: Logged |
Tyler Durden Super Geek Posts: 212 |
posted August 19, 2002 13:56
Thanks... attempting to implement now... -- Jack's pico index.html ------------------ IP: Logged |
Lex Alpha Geek Posts: 261 |
posted August 20, 2002 11:53
Wouldn't it be simpler to use the good old fashion meta refresh tag? Three versions of the page, one for each delay length, with links at the bottom to change which page you are viewing. But I'm old fashion and anti-JS. IP: Logged |
Tyler Durden Super Geek Posts: 212 |
posted August 20, 2002 18:22
quote: I might actually do that... I can't seem to get it to refresh more than twice... -- Jack's Last Resort ------------------ IP: Logged |
uilleann Highlie Posts: 721 |
posted August 24, 2002 01:09
Lex: Why? Because it looks stupid every time the entire page reloads just to update the image :) Someone had me help him with a cam page, a while back, and I got it working with code similar to the above where it reloads the image and not the page. It's actually very simple in the end, although it looks complicated. - uilleann IP: Logged |
Lex Alpha Geek Posts: 261 |
posted August 24, 2002 07:03
quote: Yeah, but it won't work with lynx... nevermind IP: Logged |
All times are Pacific Time | next newest topic | next oldest topic |
� 2002 Geek Culture� All Rights Reserved.
Powered by Infopop www.infopop.com © 2000
Ultimate Bulletin Board 5.47e