I got the following error
when I implement patent search google
in iframe
.
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>
Please help me to fix it.
Thanks in advance.
Error: In 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
Error: In Mozilla
Load denied by X-Frame-Options: https://patents.google.com/?q=dsfsdfsd&embedded=true does not permit cross-origin framing.
The website https://patents.google.com has a X-Frame-Options that allows only websites with the same domain (i.e., other Google websites only) to render its page in an <iframe>
.
So you cannot embed their website into yours. Browsers when see that the response header contains X-Frame-Options: SAMEORIGIN
, they check your domain and block the rendering of the <iframe>
. It is a security measure to avoid clickjacking.