How to ensure your page is not opened in a frame

Web programming topics
Post Reply
Tony
Lieutenant
Lieutenant
Posts: 86
Joined: Tue Jul 21, 2009 4:11 pm

How to ensure your page is not opened in a frame

Post by Tony » Sun Nov 29, 2009 4:50 am

If you want to make sure your website is not opened in a frame from some other website, put this JavaScript in the <head> of your html page:

Code: Select all

<script type="text/javascript">
if (top.location != self.location) top.location.href = self.location.href;
</script>
Post Reply

Return to “Web programming”