Adsense and AJAX: A Solution

Tired of fight with Adsense when using AJAX? That's exactly how I've been the last couple days. For such a widely spread service, it's terrible how bad flexibility for Web applications can be!
Anyways, most reputable programmers wont be relying much on iFrame, so here's an easy solution - just run this function every time you want to update the ads on your page.
I must warn you, DO NOT abuse this, Google can and will ban your account if impressions are being forced. I can't vouch that Google will even approve of this method, but from reading the ToS it should be acceptable giver the [end] user sent a request to change page content.
var redirects = 0;
function updateAdsense() {
redirects++;
var ads = document.getElementsByTagName('iframe');
var src;
if(ads && ads.length){
for (var i = 0; i < ads.length; i++){
src = ads[i].src.split('&');
if(redirects > 1)
src.pop();
src = src.join('&');
src = src + '&'+new Date().getTime();
ads[i].contentWindow.location.replace(src);
}
}
}
You can see I use "location.replace", this solves issues with Adsense updates effecting browser navigation. In basic, it makes the back button work correctly.
As you can see this code is rather lazy, I will be providing an update soon.
Update
var redirects = 0;
function updateAdsense() {
redirects++;
var ads = document.getElementsByTagName('iframe');
var src;
if(ads && ads.length){
for (var i = 0; i < ads.length && ads[i].id.substr(0,16)=='google_ads_frame'; i++){
src = ads[i].src;
if(redirects > 1) {
src = src.split('&');
src.pop();
src = src.join('&');
}
src = src + '&'+new Date().getTime();
ads[i].contentWindow.location.replace(src);
}
}
}
New Work In Progress
I'm quite excited to say I've been cracking down on alot of code these past two days. I can be quite messy at times, so I created some nice scripts and cron jobs to help me share the latest and greatest of my projects.
You can go ahead and check out my "dev" directory.
http://neotelos.com/dev/
The new directory automatically packages "snapshots" of my current progress every hour for download. Be sure to check the latest update to my AJAx Framework, major changes are in progress.
Enjoy!
WDKJD7S9V3X4
New AJAx Framework
I've decided it's about time I release something new, the last decent piece of software I released en mass was a forum script many years ago. It's time for something new.
I've got the 2nd release of my AJAx Framework with a working navigation demo. It offers great stability and much predefined functionality, such as an automated queuing system. The latest and greatest feature of all is the built-in legacy support, you can completely disable JavaScript and PHP will attempt to accommodate.
I strongly encourage developers to examine the source.
You might be surprised with what you see!
Demo - Download - Documentation - Website
Thank you Google!
My latest revision to my AJAX "framework" has been a success! Google has actually managed to scan and cache Neotelos.com, which is entirely powered by my AJAX navigation framework.
This may not sound like much to the average person, but this is a major advancement in my work.
I plan to have new and exciting uses of this feature in the near future.


