包括JavaScript? [英] Include JavaScript??

查看:66
本文介绍了包括JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的< HEAD>中有一个相当长的JavaScript < / HEAD>部分。我想将这个javaScript放在另一个文件中,然后将其包含在内。是

那可能是什么,应该只调用包含javascript的文件?

I have a rather long JavaScript in my <HEAD> </HEAD> part. I would like to
put this javaScript in another file and then just include it instead. Is
that possible and what should files containing only javascript be called??

推荐答案

JS写道:
我的< HEAD>中有一个相当长的JavaScript < / HEAD>部分。我想把这个javaScript放在另一个文件中然后只包含它。这是可能的吗?应该只调用包含javascript的文件?
I have a rather long JavaScript in my <HEAD> </HEAD> part. I would like to
put this javaScript in another file and then just include it instead. Is
that possible and what should files containing only javascript be called??




< script type = text / javascript src = myJSFile.js>< / script>


< / script>很重要:一些旧的浏览器不理解/>,

并且需要关闭某种类型。


JavaScript文件最好以a命名。 js扩展。



<script type=text/javascript src=myJSFile.js></script>

The </script> is important: some older browsers will not understand />,
and a closing of some kind is required.

JavaScript files are best named with a .js extension.


2005年5月30日10:41,Random写道:
On 30/05/2005 10:41, Random wrote:
< script type = text / javascript src = myJSFile.js>< / script>


type属性包含斜杠,因此必须引用它。 src

属性不需要在上面显示的代码段中引用,但是这样做没有伤害。

< /脚本>很重要


当然。 SCRIPT元素需要关闭标签。

一些旧浏览器不理解/> ;, [...]


这是因为它创造了HTML是乱码。我知道你推断了XHTML的使用,但是无论如何这在网上是不可行的。

此外,非空元素的元素最小化是不允许通过XHTML 1.0获得
- 附录C(虽然该部分仅提供信息)。

JavaScript文件最好以.js扩展名命名。
<script type=text/javascript src=myJSFile.js></script>
The type attribute contains a slash, so it must be quoted. The src
attribute doesn''t need to be quoted in snippet shown above, but there is
no harm in doing so.
The </script> is important
Of course. Closing tags are required for SCRIPT elements.
some older browsers will not understand />, [...]
That''s because it creates HTML that is gibberish. I know you''re
inferring the use of XHTML, but that isn''t viable on the Web anyway.
Moreover, element minimisation for non-empty elements is not permitted
by XHTML 1.0 - Appendix C (though that section is only informative).
JavaScript files are best named with a .js extension.




除非服务器配置不同,否则它们应始终以.js扩展名命名为
,否则正确的内容类型将不会是
发送。


迈克


-

Michael Winter

替换"。无效"与.uk通过电子邮件回复。



Unless the server has been configured differently, they should always be
named with a .js extension otherwise the correct content type will not
be sent.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


Michael Winter写道:
Michael Winter wrote:
On 30/05/2005 10:41,Random写道:
On 30/05/2005 10:41, Random wrote:
< script type = text / javascript src = myJSFile.js>< / script>
type属性包含斜杠,因此必须引用它。 src
属性不需要在上面显示的片段中引用,但这样做没有任何害处。
<script type=text/javascript src=myJSFile.js></script>
The type attribute contains a slash, so it must be quoted. The src
attribute doesn''t need to be quoted in snippet shown above, but there is
no harm in doing so.




通话我是一个极简主义者。我从来没有见过一个需要

报价的浏览器 - 即使是Lynx也会理解裸字,斜线或斜线。

击中那个该死的报价键经常会受伤我的小指。



Call me a minimalist. I''ve never seen a single browser that needed
quotes on it-- even Lynx understands barewords, slash or no slash.
Hitting that damned quote key so often hurts my pinky.

< / script>很重要
The </script> is important



当然。 SCRIPT元素需要关闭标签。



Of course. Closing tags are required for SCRIPT elements.




继续,真的吗?



Go on, really?

一些旧浏览器无法理解/> ,[...]
some older browsers will not understand />, [...]



那是因为它创造了乱码的HTML。我知道你推断了XHTML的使用,但无论如何这在网上是不可行的。
此外,XHTML不允许非空元素的元素最小化。 1.0 - 附录C(虽然该部分仅提供信息)。



That''s because it creates HTML that is gibberish. I know you''re
inferring the use of XHTML, but that isn''t viable on the Web anyway.
Moreover, element minimisation for non-empty elements is not permitted
by XHTML 1.0 - Appendix C (though that section is only informative).




幸运或不幸的是,一些较新的浏览器支持最小化

,即使在HTML中也是如此。因此区分。



Fortunately or unfortunately, some newer browsers do support minimising
even in HTML. Hence the distinguishment.

JavaScript文件最好用.js扩展名命名。
JavaScript files are best named with a .js extension.


除非服务器配置不同,否则它们应始终以.js扩展名命名,否则将无法发送正确的内容类型。



Unless the server has been configured differently, they should always be
named with a .js extension otherwise the correct content type will not
be sent.




这就是为什么使用.js

扩展名是最好的,但不是必需的。


你有什么有用的东西可以在这里添加,温特先生?



Which is why it is best, but not necessarily required, to use a .js
extension.

Did you have something helpful to add here, Mr. Winter?


这篇关于包括JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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