Ah, interesting. I never noticed that before.
Let me make sure I understand this correctly... the reason we still have to
"get" an element -- that is, do document.getElementById("foo") or $(foo) or
whatever, when coding JS -- is that the DOM is a feature of the user agent
(e.g. a browser engine), not part of the JavaScript language, so we can't
rely on that DOM feature for JS coding. Is that right? Apparently there's
some overlap; the page you linked to has a short list of "certain Web
browser interface elements are exposed in a limited way to scripts" but
apparently this isn't one of them.
The question remains, then: If the browser itself (including the Firebug or
other Console) may resolve elements from just a bare identifier -- but you
can't rely on that -- then how can we trust the console feedback while
writing our scripts? How can we be sure that our JS code is successfully
"getting" an element if the DOM might be doing it for us?
On Sat, Jan 2, 2016 at 1:51 PM, Simon Lindholm <[email protected]>
wrote:
> http://www.w3.org/TR/html5/browsers.html#named-access-on-the-window-object
>
> It's a DOM0 thing, and has been there since the beginning of time. If you
> remember how, back in the days, form fields used to be accessed as
> "document.formname.inputname.value", this is similar to the magic behind
> that.
>
>
> Den lördag 2 januari 2016 kl. 01:00:33 UTC+1 skrev San:
>>
>> OK, I'll try that, but there's something else going on. Forget about my
>> function; let's take the simplest possible case. Here's what I just tried:
>>
>> I created the world's simplest HTML file -- NO JAVASCRIPT AT ALL. Here's
>> the complete code:
>>
>> <!DOCTYPE html>
>> <html lang="en">
>> <head>
>> <meta charset="utf-8" />
>> <title>trashtest.html</title>
>> </head>
>> <body>
>> <p id="HUH">What is going on?</p>
>> </body>
>> </html>
>>
>> I dragged the file into Firefox, just as a file, _not_ loading it from my
>> development server. Then I opened a Firebug console, and typed in a single
>> word:
>>
>> HUH
>>
>> When I ran it, Firebug's console displayed:
>>
>> > HUH
>> <p id="HUH">
>>
>> Firebug displays the element line with syntax coloring, and it's
>> clickable to the HTML tab, including the DOM sub-tab.
>>
>> Please don't tell me it was "set by the page" -- there's NO JAVASCRIPT
>> ANYWHERE. It's not even running off my Apache server, just off the local
>> (Mac) file system.
>>
>> Chrome's console gives approximately the same result.
>>
>> Have browsers/consoles changed recently? Or is this some new HTML5
>> "convenience" that I haven't heard about? Or maybe I'm just going crazy?
>>
>> Try pasting the code above into a blank text file, and drag it into your
>> browser. Does your Firebug console not behave the same way?
>>
>>
>>
>>
>> --
> 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/cddba348-2bca-4b4f-adfb-144457b7c239%40googlegroups.com
> <https://groups.google.com/d/msgid/firebug/cddba348-2bca-4b4f-adfb-144457b7c239%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
<http://Sanstudio.com>
--
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/CAMoMLKiySe-Q_%2BUN-peAEosxfg%3D5Mrqi%2BKP97zWdKFzY_t1qNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.