Quantcast
Viewing latest article 2
Browse Latest Browse All 9

Javascript: Prevent page from frameset hijack

If you would like to prevent your site being frame by other website, you can use the code below to protect your site being frame.

Basically, the javascript check if your site is being open by frameset. It check if the opening window is top or else it will refresh the page to your site URL.

Many unethical site nowdays like to “wrap” other people website using FRAME at their website to show other website as it’s own website. This will mislead the visitor that the content is owned by them.


Frameset prevention script #1
<script type=”text/javascript”>
if (top.frames.length!=0) {
if (window.location.href.replace)
top.location.replace(self.location.href);
else
top.location.href=self.document.href; }
</script>

Frameset prevention script #2
<script type=”text/javascript”>
function breakOut() {
if (self != top)
window.open(“my URL”,”_top”,”");
}
</script>

Frameset prevention script #3
<script>
if (window!=top){top.location.href=location.href;}
</script>

Technorati Tags: , , , ,


Viewing latest article 2
Browse Latest Browse All 9

Trending Articles