Javascript 网页无法在本地主机上运行,​​但可以正常运行,文件为 :///

标签 javascript localhost ubuntu-14.04

但是...file:///home/me/public_html/path/index.html一切正常...

我正在尝试让 JavaScript 页面在本地运行。 (使用 Ubuntu 14.04 和 Apache)

当我从文件管理器打开文件 file:///home/me/public_html/path/to/index.html 目录时,网页 JavaScript 运行正常。 (通过双击index.html文件)

当我使用 localhost/~me/path/to/index.html 在 chrome/firefox 中打开它时,仅呈现 html - javascript 不会运行。

我错过了什么或没有考虑到什么?

js 源文件如下所示:

<script src="libraries/jquery-1.9.0.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="libraries/prettify/prettify.js"></script>
<script src="libraries/tinycolor.js"></script>
<小时/>

[已解决] 这是子目录权限...它们是 drwx----- 并且应该是 drwxr-xr-x - localhost 现在可以工作.

最佳答案

在 Firefox 中安装 FireBug 并查看Console 选项卡。如果您发现任何网络错误,则说明您的Apache执行请求时出现问题。

当我遇到同样的问题时,问题是我的 WAMP 堆栈无法执行请求,因为安装了 Bitnami Stacks,它干扰了 Apache WAMP。

关于Javascript 网页无法在本地主机上运行,​​但可以正常运行,文件为 :///,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30017519/

相关文章:

javascript - 为什么 Infinity == Infinity == 1/0 是错误的?

javascript - 新的 Selenium Web 驱动程序和 Firefox 出现错误。

ruby-on-rails - rails : PayPal Express Checkout Integration in Localhost

ubuntu - Docker 守护进程无法正常重启

java - 运行配置单元 0.12,出现 slf4j 错误

javascript - 用于在 JS 函数中的变量之间切换的单选按钮

javascript - 如何在 Ionic 应用程序中使用 Google Charts

javascript - 在本地主机上运行 VueJS 应用程序

javascript - 无法使用 Fetch API 从本地主机加载 Deezer API 资源

ubuntu - Hadoop-名称节点将无法启动