使用file://链接到网络位置不适用于Chrome [英] Link to a network location using file:// does not work in Chrome

查看:409
本文介绍了使用file://链接到网络位置不适用于Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的日常构建存储在共享网络目录中。我的团队希望我在结果页面上放置该位置的链接 - 最自然的地方将成为工件。点击该链接应该打开文件夹进行查看,复制等。



我尝试实现以下解决方案:创建一个重定向到网络目录的html文件并将其保存为工件。这是我生成的HTML文件(让我们称之为 LinkToInstallation.html ):

 < HTML> 
< head>
< script type ='text / javascript'>
window.location ='file://// file_server / dir_path'
< / script>
< / head>
< body>
< / body>
< / html>

Jenkins在工件中放置了一个到这个文件的链接。当我从IE浏览器中点击它时,它重新导向很好,但是从Chrome浏览器没有发生重定向,只显示一个空白页面。如果我下载文件(通过保存链接为),并使用Chrome在本地打开它 - 它可以正常工作。

( 1)是否有解决方法,以便人们不必更改Chrome设置?
(2)如果没有,Chrome应该如何设置才能正确重定向? 页面链接到 file:// URLs,除非它们本身是从 file:// URL加载的。这是为了安全防范,因为从 file:// 运行的网页有权读取系统上的任何文件。类似的限制适用于大多数其他浏览器。



您无法从共享网络目录运行内部Web服务器的任何原因?那会整齐地解决问题。


Our daily builds are stored in a shared network directory. My team wants me to put a link to that location on the results page - the most natural place would be among the artifacts. Clicking on that link should open the folder for viewing, copying, etc.

I've tried to implement the following solution: create an html file that redirects to the network directory and save it as an artifact. Here's the html file I generate (let's call it LinkToInstallation.html):

<html>
  <head>
    <script type='text/javascript'>
        window.location='file:////file_server/dir_path'
    </script>
  </head>
  <body>
  </body>
</html>

Jenkins puts a link to this file among the artifacts. When I click on it from IE it redirects just fine, but from Chrome no redirection occurs, just an empty page is displayed. If I download the file (via Save Link As) and open it locally with Chrome - it works.

(1) Is there a workaround so that people do not have to change their Chrome settings? (2) If not, how should Chrome be set up to redirect properly?

解决方案

Chrome does not permit web pages to link to file:// URLs unless they were themselves loaded from file:// URLs. This is as a security precaution, as web pages running from file:// have permissions to read any file on your system. Similar restrictions apply for most other browsers.

Any reason you can't run an internal web server from your shared network directory? That'd solve the problem neatly.

这篇关于使用file://链接到网络位置不适用于Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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