Forum Moderators: open

Message Too Old, No Replies

framebuster causing endless loop

when google adsense script is present

         

Reid

10:23 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a page that I need to put a frambuster on because it is being framed by another site. Actually there were 2 pages. On the page without adsense it works fine but when I install it on the page with adsense it causes an endless refresh loop.
here is the code

<script language="JavaScript" type="text/javascript"><!--
setTimeout ("changePage()", 3000);
function changePage() {
if (self.parent.frames.length!= 0)
self.parent.location=document.location;
}// --></script>

Is there anthing I can do to fix this other than removing adsense from this page?

Sanenet

10:45 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now, I would say that this is being caused by
self.parent.frames.length!= 0

- the script is checking to see if the page contains a frame, and if so, to continue. Adsense displays in a frame, so self.parent.frames.length is always greater than 0.

Try setting it self.parent.frames.length to 1 (self.parent.frames.length!= 1, the!= means NOT EQUAL TO).

jimbeetle

10:53 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also try checking the 'framed pages' option when you generate your Adsense code and see if that does anything.

Not sure if it would work for you, but I use a very simplified frame breaker in my <body> and have not had any problems with Adsense:

<body onload="if (self!= top) top.location = self.location">

ADDED: Actually no, don't try the 'framed pages' option, I was muddled. If the page the Adsense is on is not supposed to be framed, it shouldn't need it. Just try the simplified frame breaker and see if that works.

Reid

11:39 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jimbeetle - the simplified framebuster works great, thanks

kaled

11:44 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<head>
<script>
<!--
if (top!= self) top.location.replace(self.location.href);
-->
</script>
</head>

Kaled.