SRC =并且缺少.JS文件 [英] SRC= and missing .JS file

查看:77
本文介绍了SRC =并且缺少.JS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




无法在网上的常见问题解答中找不到答案...


关于许多javaScript的提示''他们说的网站会警告用户

关于丢失的.JS文件应该执行以下操作:

< html>

< ; head>

....

< script src =" ABC.js" ...>

alert(错误!包含的JS文件未找到...);

< / script>

< / head>

....


但它在我的IE 6和我的Mozilla 1.6中都不起作用 -

当.JS文件不存在时没有警报。

http://www.htmlhelp.com/reference/ht...al/script.html


说,

"当使用SRC属性时,嵌入的脚本将被忽略。

,当没有找到.JS时,它不会触及案例

(或者是吗?忽略了_always_?)


那么如何告诉用户没有找到要包含的.JS?


-

问候,

Paul
http://KBD.da.ru - 只有因为

才能发展
http://www.faqts.com/knowledge_base/view.phtml/aid/1661

解决方案

文章< 36 ************************* @ posted .google.com> ,保罗

Gorodyansky< pa ***** @ compuserve.com>写道:



无法在网上的常见问题解答中找不到答案...

许多javaScript ''提示''他们说的网站会警告用户
关于丢失的.JS文件应该执行以下操作:
< html>
< head>
.. 。
< script src =" ABC.js" ...>
警告(错误!未找到包含的JS文件......);
< / script>
< / head>
。 ..

但它在我的IE 6和我的Mozilla 1.6中都不起作用 - 当.JS文件不存在时没有警报。

< a rel =nofollowhref =http://www.htmlhelp.com/reference/html40/special/script.html\"target =_ blank> http://www.htmlhelp.com/reference/ht .. .al / script.html

说,
"当使用SRC属性时,嵌入的脚本将被忽略。
不接触没有找到.JS的情况
(或者是吗?忽略了_always_?)

那么如何告诉用户没有找到要包含的.JS?



我一直在试验以下内容,似乎有效。在

..js文件中,将以下语句放在顶部。

var script111loaded =" true";


现在在HTML中放入

< script type =" text / javascript">

if(!script111loaded){alert(" script 111 not loaded") };

< / script>

-

Dennis M. Marks
http://www.dcs-chico.com/~denmarks/

用dcsi.net替换domain.invalid

----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= -----
http://www.newsfeeds.com - 世界排名第一的新闻组服务!

----- ==超过100,000个新闻组 - 19个不同的服务器! = -----





Dennis M. Marks写道:

< blockquote class =post_quotes> ...
那么如何告诉用户没有找到要包含的.JS?



我一直在试验以下它似乎工作。在
.js文件中,将以下语句放在顶部。
var script111loaded =" true";

现在在HTML中放入
<脚本类型=" text / javascript">
if(!script111loaded){alert(" script 111 not loaded")};
< / script>




谢谢,它有效(但是,我必须在_html_文本的顶部声明该变量

- 否则_if_没有

工作 - 在JS控制台中只有未定义错误,至少在Mozilla 1.6中有



-

问候,

Paul


文章< c5 ************* @ ID-25072.news。 uni-berlin.de>,Paul

Gorodyansky< pa ***** @ compuserve.com>写道:



Dennis M. Marks写道:

... <那么如何告诉用户没有找到要包含的.JS?



我一直在试验以下内容并且似乎有效。在
.js文件中,将以下语句放在顶部。
var script111loaded =" true";

现在在HTML中放入
<脚本类型=" text / javascript">
if(!script111loaded){alert(" script 111 not loaded")};
< / script>



谢谢,它有效(但是,我必须在_html_文本的顶部声明该变量
- 否则_if_没有工作 - 在JS控制台中只有未定义错误,至少
在Mozilla 1.6)。




我在IE中测试过它。我应该跟随Netscape。


为什么不像if(document.getElementById){xxx}这样的测试在某些浏览器中给出一个

未定义的错误,或者是吗?


-

Dennis M. Marks
http://www.dcs-chico.com/~denmarks/

用dcsi.net替换domain.invalid

----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= -----
http://www.newsfeeds.com - 世界排名第一的新闻组服务!

----- ==超过100,000个新闻组--19个不同的服务器! = -----


Hi,

Could not find the answer neither in FAQs not on the Web...

On many javaScript ''tips'' sites they say that do warn the user
regarding missing .JS file one should do the following:
<html>
<head>
....
<script src="ABC.js" ...>
alert("Error! Included JS file not found ...");
</script>
</head>
....

But it does NOT work neither in my IE 6 nor in my Mozilla 1.6 -
no alert when the .JS file does not exist.

http://www.htmlhelp.com/reference/ht...al/script.html

says,
"When the SRC attribute is used, the embedded script is ignored."
which does not touch the case when .JS not found
(or does it? Ignored _always_?)

So how to tell the user that .JS to be included was not found?

--
Regards,
Paul
http://KBD.da.ru - was possible to develop only because
of the great article at
http://www.faqts.com/knowledge_base/view.phtml/aid/1661

解决方案

In article <36*************************@posting.google.com> , Paul
Gorodyansky <pa*****@compuserve.com> wrote:

Hi,

Could not find the answer neither in FAQs not on the Web...

On many javaScript ''tips'' sites they say that do warn the user
regarding missing .JS file one should do the following:
<html>
<head>
...
<script src="ABC.js" ...>
alert("Error! Included JS file not found ...");
</script>
</head>
...

But it does NOT work neither in my IE 6 nor in my Mozilla 1.6 -
no alert when the .JS file does not exist.

http://www.htmlhelp.com/reference/ht...al/script.html

says,
"When the SRC attribute is used, the embedded script is ignored."
which does not touch the case when .JS not found
(or does it? Ignored _always_?)

So how to tell the user that .JS to be included was not found?



I''ve been experimenting with the following and it seems to work. In the
..js file put the following statement at the top.
var script111loaded = "true";

Now in the HTML put
<script type="text/javascript">
if (!script111loaded) {alert("script 111 not loaded")};
</script>

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


Hi,

Dennis M. Marks wrote:

...
So how to tell the user that .JS to be included was not found?


I''ve been experimenting with the following and it seems to work. In the
.js file put the following statement at the top.
var script111loaded = "true";

Now in the HTML put
<script type="text/javascript">
if (!script111loaded) {alert("script 111 not loaded")};
</script>



Thanks, it works (though, I had to declare that variable
at the top of my _html_ text,too - otherwise _if_ did not
work - just has "undefined" error in JS Console, at least
in Mozilla 1.6).

--
Regards,
Paul


In article <c5*************@ID-25072.news.uni-berlin.de>, Paul
Gorodyansky <pa*****@compuserve.com> wrote:

Hi,

Dennis M. Marks wrote:

...
So how to tell the user that .JS to be included was not found?


I''ve been experimenting with the following and it seems to work. In the
.js file put the following statement at the top.
var script111loaded = "true";

Now in the HTML put
<script type="text/javascript">
if (!script111loaded) {alert("script 111 not loaded")};
</script>



Thanks, it works (though, I had to declare that variable
at the top of my _html_ text,too - otherwise _if_ did not
work - just has "undefined" error in JS Console, at least
in Mozilla 1.6).



I tested it in IE. I should have followed through with Netscape.

Why doesn''t a test like "if (document.getElementById) {xxx}" give an
undefined error in some browsers, or does it?

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


这篇关于SRC =并且缺少.JS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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