Forum Moderators: martinibuster
To prevent these errors, the change is very simple, each line of the Adsense javascript needs var at the start:
e.g.
google_ad_type = "text";
becomes
var google_ad_type = "text";
But this requires modification of the code, which is against the Google TOS.
Does everyone who uses Adsense just put up with these errors, or do other sites not get them?
Here's the one I get right now (in Firefox 1.5.0.3):
Error: missing = in XML attribute
Source File: ... googlesyndication ... show_ads.js
Line: 6, Column: 15
Source Code: <table cool width="609" height="268" border="0" cellpadding="0" cellspacing="0" align="left" gridx="16" showgridx gridy="16" showgridy>
The undeclared variable doesn't even give me a warning though.
If you want to you could try just declaring the variables before the google js inside your own script tag, that should have the same effect without actually touching their code.
I get two sorts of Warnings (which I can also see in the JavaScript console (Firefox Tools menu)):
assignment to undeclared variable google_ad_client
assignment to undeclared variable google_alternate_ad_url
assignment to undeclared variable google_ad_width
assignment to undeclared variable google_ad_height
assignment to undeclared variable google_ad_format
etc.
These are obviously from the js snippet I insert to my pages.
Then there's this kind:
reference to undefined property b.google_ad_frameborder
reference to undefined property b.google_ad_output
reference to undefined property b.google_page_url
reference to undefined property b.google_num_slots_by_channel
reference to undefined property b.google_num_slots_by_client
etc.
These are from the js file downloaded from google (show_ads.js). There are lots of this type.
Then there's this one:
function ga does not always return a value
which would be easily resolved with this line:
else return undefined;
in the offending function, but of course I can't change the file on Google's servers.
And it doesn't stop there. There are two Errors in the JavaScript console, again from Google's show_ads.js file:
Error in parsing value for property 'cursor'. Declaration dropped.
Error in parsing value for property 'border-bottom'. Declaration dropped.
Seems like a mess! This is why I posted about it. Surely it's just me - or does everyone get these errors? I am supposing they do (if they look) because well, if a variable is undefined for me, I guess it's undefined for everyone else too. I wanted to check I wasn't misunderstanding the situation. Is there something I can do? I'll be pragmatic about this - if the ads load and my page works then great. But still, avoiding a whole host of coding errors and warnings is preferable.
The "error in parsing value for..." error may result from not specifying units in a declaration.
The "reference to undefined property" is an easy fix, see
[javascriptkit.com...]
These errors are beyond my control because they result from Google's js file.
The "assignment to undeclared variable..." is also an easy fix (see earlier post in this thread and also
[javascriptkit.com...] ). The difference with this error is that it comes from the js code I paste into my pages. Actually I did make these changes to my Adsense js code snippet - before I realised this was like a mortal sin in Adsense terms and changed everything back FAST!
(I have emailed Google about this last set of errors which I could eliminate, and I'm waiting for a reply.)
[edited by: jatar_k at 5:22 pm (utc) on May 4, 2006]
[edit reason] removed url [/edit]
I don't think there are any functional problems, in which case you may think "so why worry about it". If so, good point.
But whether there could be functional problems, code conflicts etc etc is something I really don't know, which is why I posted here about the errors and warnings. I'm hoping people more knowledgeable than me on these things will let me know!
I suppose after reading enough how-to-do-web-stuff-good articles I have bought into the "write valid code" message. It's the safest way for me to proceed with my web sites too really, because though I can write valid xhtml and css, I'm not a web designer or IT pro by any means at all. So getting rid of errors and warnings is like a safety net.
Googles code is strewn with errors. Just use "tools" "Javascript console" in Firefox and then log into Adsense and watch the errors fly! This must take up CPU time, meaning it takes your visitor longer to see the webpage than it should.
Adding variable declarations in another script block outside of the Adsense code does not alter the Adsense code. I believe the language definition says "var" is optional.