Forum Moderators: open

Message Too Old, No Replies

How to prevent reframing of my pages

         

devitnow

7:13 pm on Nov 5, 2004 (gmt 0)

10+ Year Member



Can someone please tell me how or point me to a good resource on how prevent outside sites from framing my webpage content as their own.

thanks,
Devitnow

encyclo

7:25 pm on Nov 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add this to your
head
section (either inline or as a separate file as required):

<script type="text/javascript">
if (parent.frames.length > 0) {
parent.location.href = self.document.location
}
</script>

The script checks to see if the page is within a frame, and if so, it reloads just the page itself without the frame around it.

kaled

7:36 pm on Nov 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using location.replace() will ensure better handling of browser history (ie back and forward buttons).

Also, using top rather than parent may be preferred. I tend to use something like this


if (top!= self) top.document.replace(self.location.href);

However, if you use frames yourself, it gets a bit more complicated.

Kaled.

devitnow

3:07 pm on Nov 6, 2004 (gmt 0)

10+ Year Member



thanks so much. I'm tired of these sites that frame my page and run a banner ad or something in the top.