Good Deal Hosting
Please Login or Register

Knowledgebase

Automatically break out of an iframe.

Iframe stands for inline frame. An Iframe is a floating frame that can be inserted anywhere within a web page.

A concern for webmasters about iframes is that an iframe can be used to include pages on your website into external sites.

How do you prevent pages on your website from being included through an iframe by another website?

Placing the following javascript code at the top of all pages on your site will ensure that if any other site iframes a page on your website, that your page will break out of the iframe and just display your page in the users browser.

<script type="text/javascript">
	<!--
		if (top.location!= self.location) {
			top.location = self.location.href
		}
	//-->
</script>

The best way to implement this break out of an iframe code on an entire site is to put the code into an external javascript file, and include it in a common template file (i.e. header template file that is included by all pages on your website).



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article


Language:

Quick Navigation

LiveZilla Live Help

Client Login

Email

Password

Remember Me

Search



Follow Us on Twitter