避免坏< SCRIPT SRC =>挂着页面 [英] Avoiding bad <SCRIPT SRC=> hanging the page

查看:89
本文介绍了避免坏< SCRIPT SRC =>挂着页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTML页面有< SCRIPT SRC = http:// remote / script>在每页的顶部''$

。有时远程主机(可能由于负载过重或网络连接不稳定)并没有长时间响应。这个

导致整个页面显示挂起而没有任何加载。


是否有一些技巧我可以使用settimeout()以便如果远程脚本,那么我可以告诉

页面/浏览器取消加载那个脚本吗?


-

Pascal Damian

解决方案




Pascal Damian写道:

我的HTML页面有< SCRIPT SRC = http:// remote / script>在每页的顶部''
。有时远程主机(可能由于负载过重或网络连接不稳定)长时间没有响应。这导致整个页面显示悬挂而没有任何加载。

是否有一些技巧我可以使用settimeout(),以便如果远程
脚本之后无法加载,比方说,30秒,然后我可以告诉
页面/浏览器取消加载该脚本?




对于IE,如果脚本没有生成页面内容(例如不使用

document.write)尝试

< script defer type =" text / javascript"

src =" http://example.com/file.js">< / script>

-


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


Martin Honnen< ma ******* @ yahoo.de>写道:

对于IE,如果脚本没有生成页面内容(例如没有使用
document.write),请尝试
< script defer type =" text / javascript"
src =" http://example.com/file.js">< / script>




不仅仅是IE。 推迟属性在HTML 4中指定。


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>

''没有判断的信仰只会降低神灵的精神。''


Martin Honnen< ma ******* @ yahoo &由Matchi.com提供回到GT;在消息新闻中写道:< 41 ****** @ olaf.komtel.net> ...

Pascal Damian写道:

我的HTML页面有一个< SCRIPT SRC = http:// remote / script>在每页的顶部''
。有时远程主机(可能由于负载过重或网络连接不稳定)长时间没有响应。这导致整个页面显示悬挂而没有任何加载。

是否有一些技巧我可以使用settimeout(),以便如果远程
脚本之后无法加载,比方说,30秒,然后我可以告诉
页面/浏览器取消加载该脚本吗?



对于IE,如果脚本没有生成页面内容(例如不不要使用
document.write)尝试
< script defer type =" text / javascript"
src =" http://example.com/file.js"> ;< / script>




可悲的是,脚本执行document.write(...)(因为我猜大多数其他的

有趣脚本没有。


有没有办法可以做这样的事情:


< script>

如果(不能在15秒内ping /连接到远程主机的端口80){

//跳过

}否则{

document.write(''< script src = http:// remote-host / script>< / script>'');

}

}

< / script>


-

Pascal Damian


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

解决方案



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/


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


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


这篇关于避免坏&lt; SCRIPT SRC =&gt;挂着页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆