Hi for some reason when i call imagerefresh(theImgURL) the variable theImgURL does not get passed onto the next function.
does anyone know why?
[CODE]
<script language=”javascript”>
<!–
var updateImageTimerId;
var idx = 0;
function startRefresh(theImgURL){
updateImageTimerId = setInterval(“imagerefresh(theImgURL);”, 4000);
}
function imagerefresh(theImgURL){
clearInterval(updateImageTimerId);
idx ++;
if (idx <= 120){
var theDate = new Date();
var url = theImgURL;
url += “?dummy=”;
url += theDate.getTime().toString(10);
document.all.webcamImage.src=url;
}
}
startRefresh();
–>
</script>
Im new to Javascript any help would be greatfull
<i>
</i>updateImageTimerId = setInterval("imagerefresh('"+theImgURL+"')", 4000);
<i>
</i>updateImageTimerId = setInterval("imagerefresh("+theImgURL+")", 4000);
[/QUOTE]
Im new to Javascript any help would be greatfull[/QUOTE]
function startRefresh(theImgURL){
function g(){imagerefresh(theImgURL)};
updateImageTimerId = setInterval(g, 4000);
}
In what browser does that work? ? ?[/QUOTE]
All browsers that have JavaScript enabled. ?[/QUOTE]
Hi for some reason when i call imagerefresh(theImgURL) the variable theImgURL does not get passed onto the next function.
does anyone know why?[/quote]
startRefresh[COLOR=Red]()[/COLOR];
function startRefresh[color="red"](theImgURL)[/color]{
updateImageTimerId = setInterval("imagerefresh(theImgURL);", 4000);
}
How does the setInterval() function call work when it goes looking for theImageURL and can't find any variable by that name?[/QUOTE]
Even if you did send a value for theImageURL to the outer function, the setInterval() function still wouldn't be able to read it for the reasons I outlined in my other post.[/QUOTE]
updateImageTimerId = setInterval("imagerefresh(theImgURL);", 4000);
[/quote]
<i>
</i>updateImageTimerId = setInterval("imagerefresh('"+theImgURL+"')", 4000);
If you actually tried it in IE6 or FF1.0, you would at least know that it doesn't work. But, if you knew how a setTimeout() worked in the first place, you wouldn't even need to test it to know that your code
can't possibly work[/QUOTE]
It is passed as an argument -- as I demonstrated. Works fine -- lasts a long time.[/QUOTE]
function g(value)
{
setInterval( "h(" + value + ")", 4000 );
}
function h(x)
{
alert(x);
}
g("hello");
As noted, though, you must make sure you have a valid variable value in the first place[/QUOTE]So, your solution won't work?
Seems you're the one that hasn't tried it. ? I've been using it that way in IE and NN for six years -- and now Firefox, too. :p[/QUOTE]I tested your solution in both IE6 and FF1.0, and it doesn't work. I don't know what to say. I guess we are at an impass: you say it works, I say it doesn't.
I see now, you are going back and editing your original post.[/QUOTE]
So, your solution won't work?[/QUOTE]
So, you are saying, this works on your browser:
[/QUOTE]
function g(value)
{
setInterval( "h(" + value + ")", 4000 );
}
function h(x)
{
alert(x);
}
g("hello");
[CODE]echo "
<script language="javascript">
<!--
var updateImageTimerId;
var idx = 0;
function startRefresh(theImgURL){
updateImageTimerId = setInterval("imagerefresh('"+theImgURL+"')", 4000);
}
function imagerefresh(theImgURL){
clearInterval(updateImageTimerId);
idx ++;
if (idx <= 120){
var theDate = new Date();
var url = theImgURL;
url += "?dummy=";
url += theDate.getTime().toString(10);
document.all.webcamImage.src=url;
}
}
startRefresh();
-->
</script>
";
[/CODE]
[CODE]
<img alt="Regatta Hotel Dance Floor Cam" id="webcamImage" onload="startRefresh('http://203.201.149.139/corodrv/corodrv.jpg');" src="http://203.201.149.139/corodrv/corodrv.jpg" vspace="5" hspace="5" border="0">
[/CODE]
Yes, that works in all three of my browsers -- IE, NN, and Firefox -- as long as value contains numeric data.
If it contains string data, then quotes are required.[/QUOTE]
After I informed you several times that your solution didn't work in ANY browser...[/QUOTE]
Thanks i must have completely overlooked that part!
It works perfectly with one image, But for some reason it dosent work with multiple images on a page...is this a really stupid question?[/QUOTE]
<i>
</i>var updateImageTimerId;
var idx = 0;
function startRefresh(theImgURL){
updateImageTimerId = setInterval("imagerefresh(theImgURL);", 4000);
}
function imagerefresh(theImgURL){
clearInterval(updateImageTimerId);
idx ++;
if (idx <= 120){
var theDate = new Date();
var url = theImgURL;
url += "?dummy=";
url += theDate.getTime().toString(10);
document.all.webcamImage.src=url;
}
}
startRefresh();
<i>
</i>function refreshImage(imgURL, imgID, imgIDX){
if (++imgIDX <= 120){
var url = imgURL + "?dummy=" + (new Date()).getTime().toString(10);
document.getElementById(imgID).src = url;
setTimeout("refreshImage('"+imgURL+"', '"+imgID+"', "+imgIDX+")", 4000);
}
}
[code=html]
<img src="http://203.201.149.139/danceflr/danceflr.jpg"
alt="Regatta Hotel Dance Floor Cam" width="320" height="240" border="0" id="1"
onload="refreshImage('http://203.201.149.139/danceflr/danceflr.jpg', '1', '0');">
[/code]
[code=html]
<body onload="refreshImage('http://203.201.149.139/danceflr/danceflr.jpg', '1', '0');">
<img src="http://203.201.149.139/danceflr/danceflr.jpg"
alt="Regatta Hotel Dance Floor Cam" width="320" height="240" border="0" id="1">
[/code]
0.1.9 — BETA 6.16