Firefox 无法链接到本地​​或网络页面

发布于 2024-07-06 16:21:53 字数 472 浏览 8 评论 0原文

我有一个 .asp 应用程序,其中图像文件(.PDF)存储在一个目录中(由复印机/扫描仪提供)。 创建的文件名存储在数据库表中。 从网页启动查询时,会创建指向该文件的链接。 单击时应显示图像。 此功能在 Internet Explorer 中 100% 有效。 Firefox 就没有这样的运气了(我有一些 Firefox 用户)。 创建的超链接看起来像这样 file://Server/Scanner/XYZ.pdf

Firefox 帮助提示原因是这样的:

本地或网络页面的链接不起作用。 作为安全预防措施,Firefox 禁止 Internet 上的站点链接到存储在本地计算环境中的文件。 这些文件可能包括您计算机上的文件、映射的网络驱动器和 UNC 网络路径

对于解决方法的建议似乎都不起作用(或者我不理解创建图像显示的步骤) 有什么建议么?

I have a .asp application where image files (.PDF) are stored in a directory (fed by a copier/scanner). The created file names are stored in a database table. When a query is launched from the web page a link to the file is created. When clicked the image should be displayed.
This functionality works 100% in Internet Explorer. No such luck in Firefox (and I have some Firefox users). The created hyperlink looks like this file://Server/Scanner/XYZ.pdf

The Firefox helps suggest the reason is this:

Links to local or network pages do not work. As a security precaution, Firefox forbids sites on the Internet to link to files that are stored in your local computing environment. These files may include files on your computer, mapped network drives, and UNC network paths

None of the suggestions for a workaround seem to work (or I am not understanding the steps to create the image display)
Any Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

街角迷惘 2024-07-13 16:21:53

这是为安全性而设计的默认 Firefox 行为。假设大多数网站可能不知道本地文件是什么以及在哪里(包括 UNC 路径)。

这可以在 Firefox 中关闭:

  • 在地址栏中输入“about:config”并接受“我会小心的”
  • 在旧版本中查找“security.checkloaduri”或在较新版本的 Firefox 中查找“security.fileuri.strict_origin_policy”将值更改为“false”
  • 重新启动 Firefox

这应该会为您完成。 您可以在此处获取更多信息:

This is the default Firefox behavior designed for security .The assumption is probably that most web sites don't know what and where are you local files (including UNC paths).

This could be turned off in firefox:

  • type "about:config" in the address bar and accept "i'll be careful"
  • find "security.checkloaduri" in older versions or "security.fileuri.strict_origin_policy" in newer versions of firefox and change the value to "false"
  • restart firefox

That should do it for you. You have more information here:

输什么也不输骨气 2024-07-13 16:21:53

Firefox >= 68.0.1

我可以使用此处提到的设置在 Firefox 中预览带有本地文件链接的图像和 PDF 文件: https://bugzilla.mozilla.org/show_bug.cgi?id=1303727

我使用了本地文件的链接: test

并在 user.js 中添加上述设置(调整后的站点列表):

user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://my.intranet");
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

此外,当将 Firefox 设置为“始终询问”PDF 文件时,我能够在 Adob​​e Acrobat Reader DC 中“打开”PDF,它在访问“文件 -> 属性”时报告了预期的本地文件夹。


火狐 >= 1.5.x < 20 (ish)

在硬盘上搜索 Firefox 配置文件文件夹,例如(12345678 代表八个随机数字和字母):

  • Windows:“C:\Documents and Settings\Username\Application Data\Mozilla\Firefox\Profiles12345678.default\ "
  • Linux: "/home/username/.mozilla/firefox/12345678.default/"
  • OS X: /Username/Library/Application Support/Firefox/Profiles/12345678.default/

在此文件夹中创建一个名为 user.js。 将以下行写入该文本文件:

user_pref("capability.policy.default.checkloaduri.enabled", "allAccess");

适用于我的电脑(Firefox 3.0.3 和 19.0 beta),参考以下内容:

  • <
  • img src="file://\\\server\分享\image.png" />
  • <
  • img src="file://d:/image.png" //>
  • < img src="file:///d:/image.png" //code> <
  • img src="file://localhost/d:/image.png" //另外

,如果您使用的是 NoScript 附加组件,请选中高级 \ 受信任 \ 允许本地链接 选项。

Firefox >= 68.0.1

I'm able to preview in Firefox both images and PDF files with local file links using the settings mentioned here: https://bugzilla.mozilla.org/show_bug.cgi?id=1303727

I have used links with local file: <a href="file://N:/path/to/file.ext">test</a>

and added in user.js the mentioned settings (with adjusted sites list):

user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://my.intranet");
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

Also, when setting Firefox to "Always ask" for PDF files, I was able to "Open with" the PDF in Adobe Acrobat Reader DC, which reported the expected local folder when accessing "File -> Properties".


Firefox >= 1.5.x < 20 (ish)

Search for the Firefox profile folder on your hard drive, e.g. (12345678 stands for eight random digits and letters):

  • Windows: "C:\Documents and Settings\Username\Application Data\Mozilla\Firefox\Profiles12345678.default\"
  • Linux: "/home/username/.mozilla/firefox/12345678.default/"
  • OS X: /Username/Library/Application Support/Firefox/Profiles/12345678.default/

In this folder create a text file with the name user.js. Write the following line into that text file:

user_pref("capability.policy.default.checkloaduri.enabled", "allAccess");

Works on my PC (Firefox 3.0.3 and 19.0 beta) with the following references:

  • <img src="file://///server/share/image.png" />
  • <img src="file://\\\server\share\image.png" />
  • <img src="file://d:\image.png" />
  • <img src="file:///d:\image.png" />
  • <img src="file://d:/image.png" />
  • <img src="file:///d:/image.png" />
  • <img src="file://localhost/d:/image.png" />

Also, if you are using the NoScript add-on, check the Advanced \ Trusted \ Allow local links option.

难忘№最初的完美 2024-07-13 16:21:53

阅读此处给出的解决方案后,我点击了链接 本地页面链接不起作用,对我来说,只有这个效果很好(我我正在使用 WordPress 进行本地 wamp 安装的个人常见问题解答):

  • 转到“%Your Documents & Settings%\Application Data\Mozilla\Firefox\Profiles\%your profile%\”
  • 编辑文件“prefs.js”
  • 添加文档末尾的以下行:

.

user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
user_pref("capability.policy.localfilelinks.sites", "http://localhost");
user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess");

您可以将设置“security.checkloaduri”保留为默认值,也可以将“security.fileuri.strict_origin_policy”保留为默认值。 感谢这 3 行代码,您只需为本地服务器破例即可。

请注意,如果您需要返回到该 prefs.js 文件,请注意 Firefox 会按字母顺序对其进行排序。 因此,您在末尾添加的 3 行将位于开头的某个位置;)。

Reading at the solution given here, I followed the link Links to local pages do not work and for me, only this worked well (I am using wordpress for a personal FAQ on a local wamp installation):

  • Go to your "%Your Documents & Settings%\Application Data\Mozilla\Firefox\Profiles\%your profile%\"
  • edit the file "prefs.js"
  • add the following lines at the end of the document:

.

user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
user_pref("capability.policy.localfilelinks.sites", "http://localhost");
user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess");

You can leave the setting "security.checkloaduri" to its default value, and also the "security.fileuri.strict_origin_policy". Thanks to those 3 lines, you just make an exception for your local server.

Be careful, if you need to go back to that prefs.js file, note that Firefox will have ordered it alphabetically. So the 3 lines you will have added at the end will be somewhere at the beginning ;).

虐人心 2024-07-13 16:21:53

您可以加载 LocalLink FireFox 附加组件,它允许您右键单击本地链接并选择“在前台窗口中打开”。 其他“打开...”菜单项应该可以工作,但不适合我。

http://locallink.mozdev.org/

另外,您可以使用 NoScript,就像 Alex 建议的那样,它可以使正常点击本地链接。 谢谢亚历克斯。

You can load the LocalLink FireFox Add-On, which allows you to right-click on a local link and select 'Open in Foreground Window'. The other 'Open...' menu items are supposed to work, but don't for me.

http://locallink.mozdev.org/

Also, you can use NoScript, like Alex suggests, which enables normal clicking of local links. Thanks Alex.

喜你已久 2024-07-13 16:21:53

Marko 的解决方案应该适用于本地文件系统上的链接,但我认为它不应该允许 http:// 页面链接到 file:// 页面。

这里讨论了从 http:// 页面链接的人的问题:
http://kb.mozillazine.org/Links_to_local_pages_do_not_work
并解释如何规避它并使自己面临风险。

Marko's solution should work for links that are also on the local filesystem, but I don't think it should allow an http:// page to link to a file:// page.

The issue for people linking from http:// pages is discussed here:
http://kb.mozillazine.org/Links_to_local_pages_do_not_work
along with an explanation of how to circumvent it and expose yourself to risk.

私藏温柔 2024-07-13 16:21:53

您可以从磁盘读取文件,然后从您的页面将其发送到响应中。

有关示例,请参阅此链接

You can instead read the file off the disk and then send it in the Response from your page.

See this link for an example.

别闹i 2024-07-13 16:21:53

非常感谢我几个月来一直在寻找这个解决方案,

::这件事有效::

这可以在火狐浏览器中关闭

* type "about:config" in the address bar and accept "i'll be careful"
* find "security.checkloaduri" in older versions or "security.fileuri.strict_origin_policy" in newer versions of firefox and change the value to "false"
* restart firefox

::::

Tonnes of thanks I wAs searching this solution since months,

::THis thing worked::

This could be turned off in firefox:

* type "about:config" in the address bar and accept "i'll be careful"
* find "security.checkloaduri" in older versions or "security.fileuri.strict_origin_policy" in newer versions of firefox and change the value to "false"
* restart firefox

::::

や莫失莫忘 2024-07-13 16:21:53

难道你不应该真正将页面存储在应用程序目录中并以这种方式引用它们吗? http://SITENAME/Server/scanner/XYZ.pdf

我们对所有存储在一个目录中的文件执行类似的操作,只存储文件名。 然后,我们使用已知的文件夹名称创建链接并附加文件名。 这效果很好。

最后,Firefox 对文件名中斜杠的方向也更加严格。 确保它们都是“/”而不是“\”。

希望这可以帮助。

shouldn't you really store the pages in your application directory and reference them this way. http://SITENAME/Server/scanner/XYZ.pdf.

We do something similar with files stored all in one directory and just store the file name. we then create the link using the known folder name and append the file name. this works quite well.

Finally firefox is a lot more anal about the directions of the slashes in file names as well. Make sure they are all '/' rather than '\'.

Hope this helps.

不美如何 2024-07-13 16:21:53

注意与 gmarks(谷歌工具栏替换器)的不兼容
本地链接和策略经理都为我工作; 本地链接更流畅,策略管理器为您提供更多控制

beware of incompatibility with gmarks (google toolbar replacer)
both local link and policy manager worked for me; local link is a little smoother, policy manager gives you more control

筱果果 2024-07-13 16:21:53

file://localhost///servername/share/file.txt 在 FF11 上为我工作

(来自本地 html 文件:file:///C:/index.html代码>)

file://localhost///servername/share/file.txt works for me on FF11

(from a local html file: file:///C:/index.html)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文