473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Avoiding bad <SCRIPT SRC=> hanging the page

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
14 1946


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
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
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


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


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
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


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


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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MPennig | last post by:
Here's my situation. I have a function defined in my document's <head> section which adds a <script> tag to a specified <div> tag. The added <script> has a src="" attribute pointing to a PHP file,...
10
by: Blue® | last post by:
I would like to call the content of content.htm (containing only HTML codes) into index.htm. This is usually done by renaming index.htm to index.shtml and use this tag: <!--#include...
2
by: Christopher Benson-Manica | last post by:
I would like to, for debugging purposes, obtain the contents of a <script> element. I'm aware that the text property contains the text contained within the element. However, the <script> element...
1
by: JMMB | last post by:
The <script> tags work in a htm page, but when I convert it to .aspx page, it stops working? I get a IE script error. What might be the mistake here? thanks, <HTML> <HEAD> <TITLE> Teste...
2
by: Jeffrey T. | last post by:
I had some JavaScript functions defined in the <SCRIPT> section at the top of an aspx page (tested fine there). I then moved the JavaScript functions to their own separate file and then...
21
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript"...
12
by: Iddo | last post by:
Hi, I am having a strange problem... I have an HTML file which has 2 script tags: 1) <script language="javascript" id="ABC" src="ABC.js" /> 2) <script id="general" language="javascript">...
44
by: rhythmace | last post by:
W3C HTML validator passes this: .... <script type="text/javascript" src="foo.js"> <script type="text/javascript"> ....script in here... </script> ....
0
by: Puja | last post by:
hi all, am not sure if this is the right place to put this problem but i really need solution to this I have one user control called color.ascx in which am using around 5-6 javascript files.
3
by: joe | last post by:
Is it OK to have multiple: <script type="text/javascript" src="funcs1.js"></script> <script type="text/javascript" src="funcs2.js"></script> <script type="text/javascript"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.