> Also you can set "use strict" and that will cause also an error (although
> at runtime) on each undeclared variable.


Thanks... I just read a little about "use strict", which I haven't used
before, and tried to use it in this context. It didn't seem to work.
Specifically:

First I loaded an HTML file I'm working on, disabled Firebug, and cleared
the browser disk and memory caches.

The HTML contains a GIF with the id "masthead"​, like this:

<img id="masthead" src="graphics/masthead.posterFrame.gif">

Nowhere in my code do I turn "masthead" into a variable  -- in fact, I
don't try to use it in any JavaScript at all. So now I put a small script
at the bottom of the file, just before the </body></html> tags:

<script>
"use strict";
alert( masthead );
</script>

When I reload the page in Firefox, this alert pops up:

       [object HTMLImageElement]

Why doesn't it throw an error, or at least say "undefined"? I tried various
things: it makes no difference whether I include "use strict" or not; it
makes no difference whether the DTD is HTML5, 4.01 Strict, or 4.01
Transitional.

You said "use strict" only works at runtime. Doesn't an alert qualify as
runtime?

Maybe this weird, magical "getting" an element like this, which is the
problem I've been wrestling with all along... maybe that doesn't qualify as
an "undeclared variable" at all, and therefore doesn't care about "use
strict"? After all, if "use strict" is purely a JavaScript thing, but the
browser engine's DOM processing (which is independent of JS) is doing this
weird stuff, then it might have nothing to do with JS per se... but might
still creating a scripting problem (disguising an undeclared variable,
making it seem to work but unreliable) or at least make the script harder
to analyze as I work on it.

Is there something I don't understand here?

-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/firebug.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/firebug/CAMoMLKgF5BxZw-x0PiYAqK2OqD22AGa8mswcmQp2VsX4Yy1ZCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to