2017-07-14 79 views
0

我,当我实现iframepatent search google以下error错误:在一个框架,因为它设置“X-框架 - 选项”到“SAMEORIGIN”

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. 
+0

可能的重复:https://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome – Ved

+0

@我已经尝试了不同的东西。请检查我的代码... –

回答

0

网站https://patents.google.comX-Frame-Options只允许具有相同的域的网站(即其他仅限Google网站)以呈现其网页。

所以你不能将他们的网站嵌入你的网站。浏览器在看到响应头包含X-Frame-Options: SAMEORIGIN时,会检查您的域并阻止的呈现。这是避免clickjacking的安全措施。

+0

有没有可能实现我们自己的项目? –

+0

此限制仅适用于浏览器。您可以创建一个访问该网站(或API,如果可用)的后端服务,并通过端点提供结果。因此,您的网站可能会向您的服务发送请求(这将允许您的域使用CORS配置等发送请求),并通过该服务从Google专利中检索数据 –

+0

此问题的答案可能很有用:https ://stackoverflow.com/questions/32637023/using-google-patent-api –

相关问题