3

error当我patent search googleiframe.

in a frame because it set 'X-Frame-Options' to 'sameorigin'.

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;
}
<h2>Google Patent Search</h2>
<form>
  <p>Paste your content</p>
  <textarea id="patent_content"></textarea>
  <input type="button" id="go_search" value="go" />
</form>
<div id="result">
</div>

请帮我修复它。

提前致谢。

错误: 在 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

错误: 在 Mozilla

Load denied by X-Frame-Options: https://patents.google.com/?q=dsfsdfsd&embedded=true does not permit cross-origin framing.
4

2 回答 2

5

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

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

于 2017-07-14T10:00:13.373 回答
2

我也有这个问题,但你所要做的就是抓住最后一个 youtube 链接。例如,在此链接中https://www.youtube.com/watch?v=KUh2O8HylUM

KUh2O8HylUM - 复制它并在 src="https://youtube.com/embed/ here " 中,如下所示。

<iframe src="https://youtube.com/embed/KUh2O8HylUM"
        width="560" height="315" frameborder="0" allowfullscreen>
</iframe>
于 2018-06-16T08:58:22.077 回答