您可以将 window.location 设置为带有 chrome:// 的页面吗?

2024-05-03

我正在尝试将用户重定向到chrome://settings(或者这实际上可以是带有chrome://前缀)但是window.location='chrome://settings' or window.location='chrome://crash'不工作。有什么方法可以do work? .


出于安全原因,您不能执行此操作。您无法打开任何本地资源或浏览器的功能页面,这可能存在潜在危险,因此浏览器默认会阻止它。

例如,在 Firefox 中尝试执行以下代码:

window.location = 'about:preferences'

导致错误:

TypeError: Access to 'about:preferences' from script denied.

在镀铬中:

window.location = 'chrome://settings'

导致:

VM388:1 Not allowed to load local resource: chrome://settings/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

您可以将 window.location 设置为带有 chrome:// 的页面吗? 的相关文章

随机推荐