Forum Moderators: martinibuster

Message Too Old, No Replies

Attention: caution with innerHTML and AdSense

Big surprise at javascript execution

         

jetteroheller

12:14 am on Feb 3, 2009 (gmt 0)

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



I changed in the afternoon something.

Now it was like this

<div id=insert style=top:0;left:0>

some other code

<div id=ad120x90 style=top:120;left:10>AdSense code</div>
<div id=ad300x250 style=top:300;left:10>AdSense code</div>

</div>

In the javascript loaded by the page, to the DIV insert are added some components.

This add to the innerHTML had a very strange side effect on Firefox

There are later on the page 2 other ads defined, a
336x280 and a 200x90 AdLink in other colors.

When the javascript becomes executed, the 2 ads disappear, and suddenly a part of the 336x280 ad block shows up at the place of the 120x90 AdLink.

The 300x250 ad block changes to the colors of the later ads and shows a copy of the 200x90 AdLink.

Happy compiling and uploading for the rest of the night

BTW MSIE 7 just reloads the 2 ads.

For luck, I made a load time study with cellphone and video,
testing with MSIE and normal internet connection, all would be so fast, that the reload of the ads would be invisible.

encyclo

1:04 am on Feb 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<div id=ad120x90 style=top:120;left:10>AdSense code</div>
<div id=ad300x250 style=top:300;left:10>AdSense code</div>

This is both invalid HTML and invalid CSS - you must use quotes around all attributes that contain anything more than simple name characters, and you must define the units (pt, px) when declaring position values other than zero. With invalid markup like this, who knows what errors it will trigger.

jetteroheller

11:27 am on Feb 3, 2009 (gmt 0)

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



This is not the correct why.

The correct why is, that a javascript in an innerHTML becomes executed when the innerHTML is changed.