Welcome to WebmasterWorld Guest from 18.204.48.199

Forum Moderators: open

Message Too Old, No Replies

js file will not include when refreshed

javacript refresh errors

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

Junior Member

10+ Year Member

joined:May 19, 2003
posts:41
votes: 0


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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


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

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

Junior Member

10+ Year Member

joined:Feb 10, 2003
posts:188
votes: 0


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.