|
-
March 29th, 2011, 03:08 AM
#1
Help with JavaScript Code
Hello,
I have the following JavaScript:
Code:
function reloadIt1()
{
var image1 = (document.getElementById("img0").src);
image1 = image1.split('?', 2);
if (document.getElementById("img0"))
{
document.getElementById("img0").src = (image1[0]) +"?"+ Math.random();
setTimeout("reloadIt1()", 1000);
;
}
else
{
setTimeout("reloadIt1()", 1000);
}
}
{
}
This code works fine.. however, if the .src has a ? (question mark) in the URL it don't work, as it is needed to split the URL to remove the random number it creates.
I has to create a random number to the end, otherwise it won't refresh the image as it will display the cache image and won't get a new image.
So my question is, how can I get the image to refresh with a new image (based on it's orignal src)? Somehow I need a way to remove the random number it creates and replaces it with a new one, without filtering a ? (question mark) to get the random number.
Anyone got any ideas?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|