Frame busting code and AdSense

If you are tired of your site being framed by other sites or image search engines, you would certainly have thought of using some of Javascript code to kill unwanted frame. However, there is concern that this code may cause double page impression of your AdSense or other ads. To test this, I created a small experiment by adding Javascript alert near the end of my page so it runs after frame killer/redirect occurs. To my surprise, Chrome, Opera and Safari loaded two alert boxes, which effectively proved that all Javascript (including ads) is fired up twice. I solved this problem (hopefully) by stopping execution of all scripts after redirection. Here is my final code:

if (top.location != self.location) {
top.location.replace(self.location);
if(navigator.appName == "Microsoft Internet Explorer"){
window.document.execCommand('Stop');
}
else{
window.stop();
}
}

Please let me know what you think.

Post to Twitter Tweet This Post

One Comment

  1. Ilir Fekaj says:

    I forgot to mention that I tested in latest versions of these browsers: Firefox 3.5, IE 8, Opera 10, Safari 4 and Chrome 3. It is possible that older versions of Firefox and IE, which are still used very frequently, may also double your impressions.

Leave a Reply