0

我想window.location.href在工具codeandbox.io中使用。这是因为我想在发生硬页面加载的情况下进行测试。但是,我遇到了一个问题。

location.href = "http://www.google.com"

我收到此错误:

Mixed Content: The page at 'https://codesandbox.io/s/lingering-bird-nyvfi' was loaded over HTTPS, but requested an insecure resource 'http://www.google.com/'. This request has been blocked; the content must be served over HTTPS.

示例: https ://codesandbox.io/s/locationhref-usage-nyvfi (查看src/index.ts并打开开发控制台)

如何在假的虚拟浏览器中实现模拟页面加载的能力?

4

1 回答 1

0

I think it may be possible once the security criteria are met; which is limiting.

  • Use HTTPS (Avoid mixed content)
  • Use same origin

Thus this works:

window.location.href = "https://www.codesandbox.io/docs";
于 2019-05-31T23:53:11.680 回答