html - updating javascript function without realoding -
im trying build embedded web server nano wireach smt
so far have wrote code
<html> <head> <script language=javascript> function swapimage() { var val1 = "~value1~" val1=number(val1); intimage = val1; switch (intimage) { case 0: img1.src = "off.jpg"; return(false); case 1: img1.src = "on.jpg"; return(false); } settimeout("swapimage()",500) } swapimage() </script> </head> <body> <body onload="swapimage()"> <img id="img1" name="img1" src="on.jpg"> </body> </html>
through at+i commands nano wireach smt can change ~value1~ content, , sending "0" , "1" cant change images. in order change image have reload page through browser.. wonder if there anyway automatic in specified time period or better when value1 changes without reloading hole page.. maybe put on div , reload div content dont know how.. 1 last thing..searching web found similar jquery..i cant use jquery cause libs big uc..
thank you
are missing following?
var img1 = window.document.getelementbyid("img1"); function need name? !function() { var val1 = "~value1~" val1=number(val1); var intimage = val1; var img1 = window.document.getelementbyid('img1'); switch (intimage) { case 0: img1.src = "off.jpg"; return(false); case 1: img1.src = "on.jpg"; return(false); } settimeout(arguments.callee, 500); }(); it's better send function settimeout instead of string, otherwise string eval performed on string in global context - not want.
Comments
Post a Comment