是否有可能在一个JavaScript文件,而不是服务器版本的本地版本加载? [英] Is it possible to load in a local version of a JavaScript file instead of the server version?

查看:122
本文介绍了是否有可能在一个JavaScript文件,而不是服务器版本的本地版本加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚有了一个快速的问题扔出去,看看是否有一个解决方案...

Just had a quick question to throw out and see if there was a solution for this...

让我们pretend我有服务器的访问权限。
我加载了一个网页,发现他们有一个从子文件夹中的JavaScript文件加载(假设/scripts/js/some.js)

Let's pretend I have no access to the server. I load up a webpage and find out that they have a Javascript file loading from a subfolder (let's say /scripts/js/some.js)

现在,我要修改这个文件在本地和测试针对整个网站,而整个站点下载到本地文件夹。

Now, I want to make changes to this file locally and test it against the whole site without downloading the entire site to a local folder.

有谁知道的一种方法,我可以覆盖远程js文件的加载有利于它的本地/编辑副本的?

Does anyone know of a way I can override the loading of that remote js file in favor of a local/edited copy of it?

推荐答案

我居然找到了一个解决方案。过帐到这里来寻找它的人的详细信息。

I actually found a solution for this. Posting details for anyone that comes here looking for it.

Privoxy的(www.privoxy.org/)[免费]允许这种通过重定向的大部分。虽然火狐可能会因你把它挡住重定向。这意味着你很可能将无法在本地保存文件,并通过文件引用它://等/

Privoxy (www.privoxy.org/) [Free] Allows this for the most part through a redirect. Though Firefox may block the redirect depending on where you put it. This means you most likely will not be able to save the file locally and reference it via file://etc/

(我希望我有一个方法来告诉你如何的静态的拨弄JavaScript的网页上可以​​访问限制......但我还没有找到它。如果答案走来我会接受这个了。

( I wish I had a way to tell you how to statically fiddle with JavaScript on web pages you have limited access to... but I have not found it. If an answer comes along I will accept it over this. )

当然,你必须设置Privoxy的,并把它作为一个本地代理服务器。这是pretty简单,如果你只是暂时使用它:只需将浏览器与运行它指向127.0.0.1代理端口8118

Of course, you have to set up Privoxy, and use it as a local proxy server. It's pretty simple if you only use it temporarily: Just point your browser to proxy 127.0.0.1 on port 8118 with it running.

您必须添加一个重定向默认操作(选项>编辑默认操作)重定向浏览器使用新的副本:

You have to add a redirect "default action" (Options > Edit Default Actions) to redirect the browser to use your new copy:

{ +redirect{/newLocation/some.js} }
 /scripts/js/some.js

这篇关于是否有可能在一个JavaScript文件,而不是服务器版本的本地版本加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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