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

Avoiding bad <SCRIPT SRC=> hanging the page

P: n/a
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long time. This
causes the whole page to appear hanging without anything loading.

Is there some trick I can use with settimeout() so that if the remote
script cannot be loaded after, say, 30 seconds, then I can tell the
page/browser to cancel loading that script?

--
Pascal Damian
Jul 23 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a


Pascal Damian wrote:
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long time. This
causes the whole page to appear hanging without anything loading.

Is there some trick I can use with settimeout() so that if the remote
script cannot be loaded after, say, 30 seconds, then I can tell the
page/browser to cancel loading that script?


For IE if the script doesn't generate page content (e.g. doesn't use
document.write) try
<script defer type="text/javascript"
src="http://example.com/file.js"></script>

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

P: n/a
Martin Honnen <ma*******@yahoo.de> writes:
For IE if the script doesn't generate page content (e.g. doesn't use
document.write) try
<script defer type="text/javascript"
src="http://example.com/file.js"></script>


Not just IE. The "defer" attribute is specified in HTML 4.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3

P: n/a
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41******@olaf.komtel.net>...
Pascal Damian wrote:
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long time. This
causes the whole page to appear hanging without anything loading.

Is there some trick I can use with settimeout() so that if the remote
script cannot be loaded after, say, 30 seconds, then I can tell the
page/browser to cancel loading that script?


For IE if the script doesn't generate page content (e.g. doesn't use
document.write) try
<script defer type="text/javascript"
src="http://example.com/file.js"></script>


Sadly, the script does document.write(...) (as I guess most other
interesting scripts do).

Is there a way I can do something like this:

<script>
if (can't ping/connect to port 80 of remote-host in 15 seconds) {
// skip
} else {
document.write('<script src=http://remote-host/script></script>');
}
}
</script>

--
Pascal Damian
Jul 23 '05 #4

P: n/a


Lasse Reichstein Nielsen wrote:
Martin Honnen <ma*******@yahoo.de> writes:

For IE if the script doesn't generate page content (e.g. doesn't use
document.write) try
<script defer type="text/javascript"
src="http://example.com/file.js"></script>

Not just IE. The "defer" attribute is specified in HTML 4.


But Mozilla ignores it for instance so that is why I labelled that
solution as working with IE where I know it to work.
What are your experiences with Opera 7, does it take the defer attribute
into account?

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #5

P: n/a


Pascal Damian wrote:

Is there a way I can do something like this:

<script>
if (can't ping/connect to port 80 of remote-host in 15 seconds) {
// skip
} else {
document.write('<script src=http://remote-host/script></script>');
}
}
</script>


No, certainly not with client-side script, there might be browsers
allowing their users to specify when to to abort a connection attempt
but script doesn't allow for that.

There are some browsers that would allow you to make a HTTP HEAD request
with scripting but you can't specify a timout limit for that either

http://unstable.elemental.com/mozill...tpRequest.html
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #6

P: n/a
On 11 Aug 2004 00:27:30 -0700, pa**********@icqmail.com (Pascal
Damian) wrote:
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41******@olaf.komtel.net>...
Pascal Damian wrote:
> My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
> of each page. Sometimes the remote host (probably due to heavy load or
> flaky network connectivity) doesn't respond for a long time. This
> causes the whole page to appear hanging without anything loading.
>
> Is there some trick I can use with settimeout() so that if the remote
> script cannot be loaded after, say, 30 seconds, then I can tell the
> page/browser to cancel loading that script?


For IE if the script doesn't generate page content (e.g. doesn't use
document.write) try
<script defer type="text/javascript"
src="http://example.com/file.js"></script>


Sadly, the script does document.write(...) (as I guess most other
interesting scripts do).

Is there a way I can do something like this:

<script>
if (can't ping/connect to port 80 of remote-host in 15 seconds) {
// skip
} else {
document.write('<script src=http://remote-host/script></script>');
}
}
</script>

Why not ask the remote host for their permission to use the script
then take a copy of it and use it from your own server?

Al.

Jul 23 '05 #7

P: n/a


Martin Honnen wrote:

Lasse Reichstein Nielsen wrote:
Martin Honnen <ma*******@yahoo.de> writes:

For IE if the script doesn't generate page content (e.g. doesn't use
document.write) try
<script defer type="text/javascript"
src="http://example.com/file.js"></script>


Not just IE. The "defer" attribute is specified in HTML 4.

But Mozilla ignores it for instance so that is why I labelled that
solution as working with IE where I know it to work.
What are your experiences with Opera 7, does it take the defer attribute
into account?


I just tested with Opera 7.50 and it seems to ignore the defer attribute
the same way Mozilla does.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #8

P: n/a


Martin Honnen wrote:

I just tested with Opera 7.50 and it seems to ignore the defer attribute
the same way Mozilla does.


This is the test case:
http://home.arcor.de/martin.honnen/j...004081101.html

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #9

P: n/a
Hi,

I think you're trying to remove the ads on your free web pages.
It's difficult.
Buy your own site and get full control of your pages.

Kien

pa**********@icqmail.com (Pascal Damian) wrote in message news:<6b*************************@posting.google.c om>...
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long time. This
causes the whole page to appear hanging without anything loading.

Is there some trick I can use with settimeout() so that if the remote
script cannot be loaded after, say, 30 seconds, then I can tell the
page/browser to cancel loading that script?

Jul 23 '05 #10

P: n/a
Kien wrote:
I think you're trying to remove the ads on your free web pages.
It's difficult.


It's illegal.
PointedEars
Jul 23 '05 #11

P: n/a
Thomas 'PointedEars' Lahn wrote:
Kien wrote:

I think you're trying to remove the ads on your free web pages.
It's difficult.

It's illegal.


No its not.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #12

P: n/a
Nope, wrong guess. :-) I'm trying to _keep_ the ads on my pages (which
is hosted at a cost which I pay for, thank you very much).

The problem is, the ad network is rather flaky, sometimes they're
having network difficulty. So when that happens, my visitors are
stuck. The pages can't load.

Someone will soon say, "why don't you just switch to another ad
network?". Which of course is not a wrong suggestion, but irrelevant
to my original question.

--
Pascal Damian

ca*********@hotmail.com (Kien) wrote in message news:<16**************************@posting.google. com>...
Hi,

I think you're trying to remove the ads on your free web pages.
It's difficult.
Buy your own site and get full control of your pages.

Kien

pa**********@icqmail.com (Pascal Damian) wrote in message news:<6b*************************@posting.google.c om>...
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long time. This
causes the whole page to appear hanging without anything loading.

Is there some trick I can use with settimeout() so that if the remote
script cannot be loaded after, say, 30 seconds, then I can tell the
page/browser to cancel loading that script?

Jul 23 '05 #13

P: n/a
On Wed, 11 Aug 2004 22:24:58 -0400, Randy Webb <Hi************@aol.com>
wrote:
Thomas 'PointedEars' Lahn wrote:
Kien wrote:
I think you're trying to remove the ads on your free web pages.
It's difficult.


It's illegal.


No its not.


Illegal is the wrong word, but it is forbidden in virtually every single
case[1] and liable to result in the termination of your service (if
discovered).

Mike
[1] I say "virtually" because there's bound to be a host somewhere that
neglected to add a "don't remove our banners/pop-ups" clause into the
Terms and Conditions agreement.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
Jul 23 '05 #14

P: n/a
Michael Winter wrote:
On Wed, 11 Aug 2004 22:24:58 -0400, Randy Webb <Hi************@aol.com>
wrote:
Thomas 'PointedEars' Lahn wrote:
Kien wrote:

I think you're trying to remove the ads on your free web pages.
It's difficult.
It's illegal.

No its not.

Illegal is the wrong word, but it is forbidden in virtually every
single case[1] and liable to result in the termination of your service
(if discovered).


Correct. Doesn't make it illegal, makes it a violation of the terms of
service. Pointed Head seems to be on a diatribe of late about the use of
particular words. If he wants to point fingers about the use of words,
he should take more care in his choice of words himself. YKWIM?
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.