java脚本的绝对文件路径 [英] Absolute file path for java script

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

问题描述

我有一个自己编写的小型 javascript 库.我想在我的网络应用程序中引用它,但它不起作用

I have a small javascript library written by myself. I want to reference it in my web application, but it doesn't work

<script src='file:\C:PathToScriptScript.js'></script>

当你只知道绝对路径时,是否可以引用 javascript?

Is it possible to reference javascript when all you know is the absolute path?

推荐答案

file: url需要3个正斜杠,路径也需要正斜杠:

The file: url needs 3 forward slashes, and the path also needs forward slashes:

<script src='file:///C:/Path/To/Script/Script.js'></script>

这当然只有在您在浏览器中加载的磁盘上的 html 文件中加载脚本时才有效.

This will ofcourse only work if you load the script within a html-file on your disk that's loaded in your browser.

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

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