从本地的JS文件读取的Firefox网页 - 访问受限制的URI被拒绝,code:1012,nsresult:NS_ERROR_DOM_BAD_URI被拒、网页、文件、Firefox

2023-09-10 18:00:32 作者:顾欢

我的问题是 - 我有一个html文件,这实在是JS的程序,其内容的网页,并显示在定制的方式(即它显示以不同的方式同样的内容)

My problem is -- I have a html file which is really JS program, which reads web pages and show them in customized manner (i.e. it displays the same content in a different way).

基本上,我创建XMLHtt prequest对象,然后

Basically, I create XMLHttpRequest object and then

  req.open("GET", web_page_address, false);
  req.send("");

这给了我(在Firefox)错误:

This gives me (in firefox) an error:

  错误:未捕获的异常:[异常...访问受限制的URI被拒绝code:1012nsresult:0x805303f4(NS_ERROR_DOM_BAD_URI)

Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"

我已经用Google搜索,并看了看左右,但所有其他问题都与那些非常相似的两个例外

I already googled, and looked at SO but all other issues are very similar with those two exceptions:

我在Firefox中打开该文件是本地文件,直接在浏览器中打开 - 我没有WWW服务器上运行的本地主机

我没有在网页上,我从阅读的东西任何控制

那么,几种解决方案,我到目前为止看到的(如添加PHP代理,不断变化的外部服务器发送数据的方式),不能应用在这里。

So, several solutions I've seen so far (like adding PHP proxy, changing the way external server sends data) cannot be applied here.

还有什么可以在这样的情况下做些什么呢?另一种说法是我想知道是否如此严格的安全性直接本地文件有任何意义。

What else can be done in such case? Another story is I am wondering if such strict security for directly local file has any sense.

感谢您事先提示/链接/等。

Thank you in advance for tips/links/etc.

有一个愉快的一天!

编辑:任何直接的方法是行不通的,因为Firefox没有这样的目的: https://bugzilla.mozilla.org/show_bug.cgi?id=560488

edit: Any straightforward way won't work because Firefox does this on purpose: https://bugzilla.mozilla.org/show_bug.cgi?id=560488

推荐答案

我不认为你可以做到与安装任何东西。

I don't think you can do anything with that setup.

总之,绝望不是!由于这看起来我反正喜欢的事与控制的用户群,你可以用一个Firefox扩展这样做。扩展有镀铬特权,你可以从任何你想要的域的任何页面。

Anyway, despair not! As this looks to me anyway like something with a controlled user base, you can do the same with a Firefox extension. Extensions have chrome privileges and you can get any page from any domain you want.

如果你只是想修改一些页面,你也可以考虑 Greasemonkey的< /一>,并开始编写一些JavaScript修改网页,而没有学会如何做一个扩展。 (不,扩展是很难!)

If you only want to modify some pages, you can also look into Greasemonkey, and start writing some javascript to modify a web page without bothering to learn how to make an extension. (Not that extensions are difficult!)