2017-07-14 138 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 –

相關問題