简体   繁体   English

用JavaScript调用外部脚本

[英]Calling External Scripts in JavaScript

I tried calling a external javascript script using this format, but nothing appeared in my browser (both IE & Firefox): 我尝试使用此格式调用外部javascript脚本,但浏览器(IE和Firefox)均未显示任何内容:

<script type="text/javascript" src="projectABC.js"></script>

Why is nothing appearing? 为什么什么也没出现?

Make sure that projectABC.js exists in the place the client will look for, or define "rules" on your webserver. 确保客户端要查找的位置存在projectABC.js,或在您的Web服务器上定义“规则”。 You can look at the definite path of the .js-file using a developer-tool, such as firebug. 您可以使用开发人员工具(例如firebug)查看.js文件的确定路径。

Furthermore, you don't have to declare type (anymore). 此外,您不必再声明类型。

Or do you mean not even the script-tag appears? 还是您不是说脚本标签都没有出现? If so, have you already tried to clear the cache? 如果是这样,您是否已经尝试清除缓存?

Make sure that the script file that is called must exists in the same directory of the project, other wise use the absolute path to define the location. 确保被调用的脚本文件必须存在于项目的同一目录中,否则,请使用绝对路径定义位置。 or if the file is called from outer source then the complete url like http:\\... defining the location must be specified. 或者,如果文件是从外部源调用的,则必须指定定义位置的完整URL,例如http:\\...。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM