【发布时间】:2021-10-12 13:29:20
【问题描述】:
我正在尝试使用 Electron 创建一个桌面应用程序,但我无法在 iframe 中加载像 google.com 这样的外部 URL。
下面的代码,在index.html 中,会触发一个错误。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
<iframe src="http://www.w3schools.com"></iframe>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</body>
</html>
错误:
index.html:1 Refused to display 'https://www.w3schools.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
www.w3schools.com/ Failed to load resource: net::ERR_BLOCKED_BY_RESPONSE
是什么导致了这个问题,我该如何解决?
【问题讨论】: