Welcome to WebmasterWorld Guest from 18.206.48.142

Forum Moderators: martinibuster

Message Too Old, No Replies

undeclared variables from Adsense js

but to declare the variables would require modifying the code

     
11:48 am on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


I get 12 "undeclared variable" javascript errors from my Adsense code snippet.

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?

12:17 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 24, 2005
posts:121
votes: 0


What browser are you using? Because an undeclared variable is a 'warning' message rather than a terminating error, and most browsers dont throw up visual errors for warnings.

Incidentily, even in developer mode in FireFox, I haven't seen that error....

12:25 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


Latest Firefox with the Web Developer extension.

The "errors" (which are warnings really) are of this form:

e.g
"assignment to undeclared variable google_ad_client"

I get them wherever I have the Adsense ad on my site (validated xhtml etc).

12:26 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


Sorry, I meant the FireBug extension.
12:31 pm on May 4, 2006 (gmt 0)

Preferred Member

joined:Apr 17, 2006
posts:433
votes: 0


could be why our CTR is so low :(
12:36 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 24, 2005
posts:121
votes: 0


Do you get it on other sites using Adsense? The only errors I can get to appear in FF are invalid CSS values for cursor, border-top and line-height?
2:14 pm on May 4, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Dec 22, 2004
posts:211
votes: 0


I always get errors in the js served from Google.

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.

2:46 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


MyGen: I don't have Adsense on any other site as yet. I'm an Adsense newbie.

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.

2:49 pm on May 4, 2006 (gmt 0)

Senior Member

joined:Oct 27, 2001
posts:10210
votes: 0


You can't modify the AdSense code without violating the terms and conditions, so why not simply point out the errors to Google?
2:56 pm on May 4, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member jomaxx is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 6, 2002
posts:4768
votes: 0


Is there a functional reason this needs to be fixed? Is there actually any group of people who will see error boxes or blank spaces? Or are you just trying to get Google to pretty up their code?
3:03 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


Europeforvisitors: Yes I think I might.

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]

3:11 pm on May 4, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


Jomaxx - good question.

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.

7:38 pm on May 4, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 13, 2004
posts:833
votes: 12


One good reason to get rid of errors is they must obviously impact page rendering performance. If the javascript interpreter is taking the time to determine an error, this is using CPU time that could have been used to render the page.

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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members