Rishi Kumar Rishi Kumar - 1 year ago 94
HTML Question

how to block website from loading in iframe?

Recently i tried to load youtube website in an iframe, but i checked that it's not worked. i used this simple code.

<!DOCTYPE html>
<iframe width="1000px" height="700px" src="http://www.youtube.com" ></iframe>

  1. i want to know , why my webpage can't load youtube website in

  2. what code i use to load the youtube website in my webpage.

  3. how i use same techniq in my website, so no one can add my website
    in iframe.

Answer Source

You can use HTTP Header Field X-Frame-Options,

  <meta http-equiv="X-Frame-Options" content="deny">

There are three possible values for X-Frame-Options:

DENY - The page cannot be displayed in a frame, regardless of the site attempting to do so.

SAMEORIGIN - The page can only be displayed in a frame on the same origin as the page itself.

ALLOW-FROM uri - The page can only be displayed in a frame on the specified origin.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download