Forum Moderators: open

Message Too Old, No Replies

js file will not include when refreshed

javacript refresh errors

         

IPfreely

3:13 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



hello!

i wrote a script that flips through different quotes every few seconds. problem is when someone refreshes the page the .js file seems not to include! sometimes there is an error, sometimes not -what gives?!

i don't know if i'm allowed to post the link to the file on this forum so let me know if you want to see the script.

btw using IE 6 on pc.

thanks guys,
IPfreely

Purple Martin

2:42 am on Jan 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That sort of intermittent error can be caused by using frames: when you have JavaScript in one frame that relies on some other JavaScript in another frame that may or may not have finished loading. Make sure everything is loaded before triggering your quotes script to start.

HTH

ricfink

12:27 am on Jan 10, 2004 (gmt 0)

10+ Year Member



I don't know how you're handling the reload but in the past I've gotten over the problem with a javascript function that periodically re-sets the src property of the script element using the name of the .js file along with a randomly generated search string of numbers attached to it.
something like:

-- some script to generate the string --
var sourcename = originalsourcename
document.getElementById('scriptelementid').src = sourcename + '?' + randomstring

The searchstring is disregarded by the .js file, of course, but it fools the browser into thinking it's a fresh, never-before-requested .js file.

Never failed to work for me.