When I open a page with the doubleclick url, I get no redirect happening at all. I just get a 1x1 gif pixel, which has nothiing to do with yahoo at all.
How do you get yahoo from the doubleclick tracking image?
I was using yahoo as an example. That DoubleClick serves ads and that is a dummy url i provided. I am trying to sense if there is an ad being served- If there is no ad booked it serves a default.gif if there is an ad it servers whatever.jpg.
I am trying to write a script to sense if the DoubleClick URL is serving a real ad or a 1x1. I need to find a way to process the doubleclick url on load to see if it is serving a real ad or a blank 1x1.gif.
if (mySplitResult[1] == "1x1.gif"){
document.write("hide ad");
}else{
document.write("show ad");
}
Just make an img element with the doubleclick link
var url = 'http://ad.doubleclick.net/ad/website.com/;sect=;subs=;sz=115x77;ord=4771639';
var img = document.createElement('img');
img.setAttribute('src', url);
Then you can check its width.
if (img.width == 1) {
alert('This is a 1x1 ad');
}
Now you can chuck it into a function and return the result.
function testImageWidth(url) {
var img = document.createElement('img');
img.setAttribute('src', url);
return img.width;
}
var url = 'http://ad.doubleclick.net/ad/website.com/;sect=;subs=;sz=115x77;ord=4771639';
if (testImageWidth(url) == 1) {
// bugger off
} else {
// use it
}
Hmm, this doesnt work in the new version of FireFox 2.0 - it does work on FF 1.0 and also in IE
<script>
// Ad is OFF - This returns a 1x1 ad
var url = 'http://ad.doubleclick.net/ad/website.com/;sect=;subs=;sz=115x77;ord=4771639';
var img = document.createElement('img');
img.setAttribute('src', url);
if (img.width == 1) {
alert('This is a 1x1 ad');
}
function testImageWidth(url) {
var img = document.createElement('img');
img.setAttribute('src', url);
return img.width;
}
if (testImageWidth(url) == 1) {
// bugger off
document.write("Ad Off - width="+testImageWidth(url));
} else {
// use it
document.write("Ad On - width="+testImageWidth(url));
}
</script>