JavaScript to stop people hotlinking your site through iFrames

Sam Deering
Tweet

For anyone who is interested in blocking their site off – a concern is that an iframe can be used to include pages on your website into external sites. So to prevent people hotlinking your site’s webpages through iFrames simply include this script at the top of your pages.

Also see related posts:
JQUERY CHECK IF WINDOW IS IN IFRAME
JQUERY RELOAD AN IFRAME
GETTING THE SRC OF AN INJECTED IFRAME WITH JQUERY

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

Free JavaScript: Novice to Ninja Sample

Get a free 32-page chapter of JavaScript: Novice to Ninja and receive updates on exclusive offers from SitePoint.

  • http://twitter.com/100r0bh saurabh mahajan

    cool