错误:在框架中,因为它将“X-Frame-Options”设置为“sameorigin”

Mat*_*ala 3 javascript google-patent-search

我得到了以下error的时候我实现patent search googleiframe

in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Run Code Online (Sandbox Code Playgroud)

in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Run Code Online (Sandbox Code Playgroud)
document.getElementById("go_search").onclick = function() {
  myFunction();
};

function myFunction() {
  var patent_content = document.getElementById("patent_content").value;

  var html_content = '<iframe crossorigin="anonymous" src="https://patents.google.com/?q=' + patent_content + '&embedded=true" height="200" width="300"></iframe>';
  document.getElementById("result").innerHTML = html_content;
}
Run Code Online (Sandbox Code Playgroud)

请帮我修复它。

提前致谢。

错误: 在 Chrome 中

patent.html:1 Refused to display 'https://patents.google.com/?q=fghfhfghfg' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
patent.html:24 GET https://patents.google.com/?q=fghfhfghfg net::ERR_BLOCKED_BY_RESPONSE
Run Code Online (Sandbox Code Playgroud)

错误: 在 Mozilla 中

Load denied by X-Frame-Options: https://patents.google.com/?q=dsfsdfsd&embedded=true does not permit cross-origin framing.
Run Code Online (Sandbox Code Playgroud)

Alb*_*res 5

网站https://patents.google.com有一个X-Frame-Options,它只允许具有相同域的网站(即仅限其他 Google 网站)以<iframe>.

所以你不能将他们的网站嵌入到你的网站中。浏览器在看到响应头包含 时X-Frame-Options: SAMEORIGIN,会检查您的域并阻止<iframe>. 这是一种避免点击劫持的安全措施。