[英]How to open a local file path in new tab in my browser using javascript?
window.open(URL, '_blank')
this is not working with local file it's give error "Not allowed to load local resource"这不适用于本地文件,它给出错误“不允许加载本地资源”
my local file path is like bellow我的本地文件路径如下
file:///var/www/html/proj/proj.pdf文件:///var/www/html/proj/proj.pdf
There is a simple fix and solution for your problem.您的问题有一个简单的修复和解决方案。 Obviously, there are security systems in I assume you are using chrome.
显然,我假设您使用的是 chrome,其中有安全系统。
If it's an image, please use: https://imgbb.com If it's a file such as a folder, text, zipped file, etc. Please use: https://app.mediafire.com/myfiles OR https://easyupload.io如果是图片,请使用: https://imgbb.com如果是文件夹、文本、压缩文件等文件,请使用: https://app.mediafire.com/myfiles或https://轻松上传.io
I hope this answers your question, If the solutions above do not work.我希望这能回答您的问题,如果上述解决方案不起作用。 Please leave a reply.
请留言。
I think it's impossible to open local resources via javascript, as it will be considered a security violation to protect users from malicious pages stealing their data.我认为通过 javascript 打开本地资源是不可能的,因为它会被视为安全违规,以保护用户免受恶意页面窃取他们的数据。 You can flag your browser to allow it.
您可以标记您的浏览器以允许它。 But it won't work in unflagged browsers.
但它不适用于未标记的浏览器。
If this question does not solve it, I think it's not possible to do: Open a local HTML file using window.open in Chrome如果这个问题没有解决,我认为这是不可能的: Open a local HTML file using window.open in Chrome
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.