脚本标记从file:///而不是http://加载 [英] Script tag is loading from file:/// instead of http://

查看:117
本文介绍了脚本标记从file:///而不是http://加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个简单的HTML测试页面。我正在使用Chrome版本40.0.2214.115打开它。为了测试代码,我从我的工作区加载一个js文件。

I am working with a simple HTML test page. I am opening it with Chrome version 40.0.2214.115. In order to test the code, I am loading a js file from my workplace.

但是,我加载的文件试图通过脚本标签加载其他js文件,但是没有指定http://。这会导致控制台出错,因为它默认为file:///协议,无法加载文件://the/restof/theurl.js

However, the file which I loaded tries to load other js files through script tags, but does not specify http:// . This causes an error in the console, as it defaults to the file:/// protocol and is unable to load file://the/restof/theurl.js

我在本地下载了文件,并从那里加载了它,将http://添加到所有网址,因此它实际上会使用HTTP协议。

I downloaded the file locally, and loaded it from there, adding http:// to all url's, so it would ACTUALLY use the HTTP protocol.

这很好用。但是,这些链接加载的OTHER文件也没有指定http://

This worked fine. However, those links load OTHER files that also do not specify http://

我有什么方法可以让浏览器暗示http://指向未指定的脚本标记,并避免下载和编辑每个文件只是为了测试一个小的HTML页面?

Is there any way I can have the browser imply http:// to unspecified script tags, and avoid downloading and editing EVERY file just to test a small HTML page?

推荐答案

考虑使用一个简单的本地文件服务器。如果你不确定如何,因为你是用JavaScript开发的,你可以使用 Node.js 轻松创建一个简单的文件服务器。使用简单的中间件(如 node-static )用JS编写的。

Consider using a simple local file server. If you are unsure how to, since you are developing in JavaScript, you can easily create a simple file server using Node.js which written in JS using simple middleware like node-static.

这篇关于脚本标记从file:///而不是http://加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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