1

Does anyone know a way to parse a DIV from an html frame into a visible frame using JavaScript?

For example, if I make an hidden frame of Google search results and show on the visible frame only the search results element without the search box, menu tabs, etc.

Blachshma
  • 17,097
  • 4
  • 58
  • 72
Sammy Miri
  • 123
  • 9

1 Answers1

0

If you put google's website in an frame or iframe you'll get the javascript Exception with text: "Refused to display document because display forbidden by X-Frame-Options."

Google does not allow to put the site in an iframe.

To forbid your website in an iframe you can use code like this:

var inIframe = function() {
    return (top != self);
};

jQuery(document).ready(function() {
    if (inIframe()) { throw new Error("Refused to display document because display forbidden by X-Frame-Options."); }

    // load site
});
algorhythm
  • 8,530
  • 3
  • 35
  • 47