Javascript Src路径 [英] Javascript Src Path

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

问题描述

您好我的Index.html文件中的以下代码有问题:

Hello I'm having some trouble with the following code within my Index.html file:

<SCRIPT LANGUAGE="JavaScript" SRC="clock.js"></SCRIPT>

这适用于我的 Index.html 文件与 clock.js 位于同一文件夹中。 Index.html和clock.js都在我的根文件夹中。

This works when my Index.html file is in the same folder as clock.js. Both Index.html and clock.js are in my root folder.

但当我的index.html在这些不同的目录中时,clock.js无法加载:

But when my index.html is in these different directories clock.js does not load:

/products/index.html
/products/details/index.html

我可以把什么作为'SRC',以便它总是寻找 clock.js 在根文件夹中?

What can I put as the 'SRC' so that it will always look for clock.js in the root folder?

提前致谢!!

推荐答案

尝试:

<script src="/clock.js"></script>

注意正斜杠。

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

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