Columnizer-jQuery-Plugin icon indicating copy to clipboard operation
Columnizer-jQuery-Plugin copied to clipboard

Javascript, and iframes

Open chrisgraham opened this issue 12 years ago • 0 comments

Columnizer borks adsense really badly. Actually it crashes IE7 completely, and crashes a tab process on IE8.

After a few hours of debugging this and trying various patches, I have not been able to resolve it, and I don't think it can be resolved. So I think it needs documenting instead.

Adsense uses an iframe, which is outputted via Javascript, filled via Javascript, and itself contains Javascript. That just borks for various reasons on different browsers.

I tried patching Columnizer to support a new "protectme" class which would isolate a DOM node into a buffer, remove it from the document tree, and put it back after Columnizer fixes it. Therefore it would not be clone'd (Columnizer clones stuff a lot and it's kind of inevitable for performance). But all browsers bork even on that. Chrome does a reload of the iframe, as does Firefox I think. That causes an ad reload, which Google are not going to like. I think IE just loses the contents completely (as it was written via direct writing, not an iframe src, and IE isn't preserving that) and then it dies because JS events are firing off dead content.

"protectme" is a useful patch though for other scenarios, so I am going to keep it in my "jquery fork" (I've given a URL to this in another issue).

I tried deferring adsense loading, but there's no way to do that. You can't do an after-the-fact document.write, and adsense won't let you run it via innerHTML (probably because it's expected DOM load methods aren't getting fired).

You can't also try and make adsense reload itself fully after Columnizer runs, it just won't do that either.

There are various posts out there talking about moving adsense around using DOM methods. But if they worked once, they don't work now. Or maybe they only work pre-DOM-ready.

So to recap, I implemented a "protectme", which is useful. But generally you can't use adsense with Columnizer and that needs documenting.

chrisgraham avatar Feb 10 '12 21:02 chrisgraham