By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,764 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Timeout on loading .js script

P: n/a
How can I let my script try to load a .js file and then if the .js
file doesn't load in a selected time period print an apology move on
with the rest of the page.

For instance I am using this line but sometimes the http site is down
and then my page doesn't load.

<script src="http://xxxx.com/frame.js"></script>

Cheers

Oct 11 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Steve said the following on 10/11/2007 10:00 AM:
How can I let my script try to load a .js file and then if the .js
file doesn't load in a selected time period print an apology move on
with the rest of the page.
For instance I am using this line but sometimes the http site is down
and then my page doesn't load.

<script src="http://xxxx.com/frame.js"></script>
Put a variable in the frame.js file and then use setTimeout to see if
that variable exists or not. The problem would come in with IE. In IE,
if frame.js doesn't load (for whatever reason), then it loads a 404
error page instead and will throw an "Illegal Character" error message.
Once you have made the request for the file, the only reliable way to
end the request for that file is to navigate away or reload the page and
start over.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Oct 11 '07 #2

P: n/a
Steve said:
[snip] sometimes the http site is down and then my page doesn't load.
What does the script do? Can you replicate its functionality with a
script of your own that is hosted on a more reliable site?

Oct 12 '07 #3

P: n/a
drink.the.koolaid said the following on 10/12/2007 1:24 PM:
Steve said:
>[snip] sometimes the http site is down and then my page doesn't load.

What does the script do? Can you replicate its functionality with a
script of your own that is hosted on a more reliable site?
Why are you replying to my post when your reply is intended for someone
else? Don't blame Google Crap, it is your responsibility to reply
properly, not Google Craps, err, Google Groups.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Oct 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.