nichemtktg — 2011-09-05T13:12:15-04:00 — #1
What is "document.body.appendChild(nwdiv);" doing in this function? I would just be guessing.
var txt='hello world!';
nichemtktg — 2011-09-07T10:24:41-04:00 — #2
I love it how a topic can lead to issues that I didn't even know are questions. That just reminds me that there's plenty out there, that I don't know that I don't know.
Thanks for your help Mittineague, AussieJohn, and felgall.
aussiejohn — 2011-09-06T20:09:46-04:00 — #3
nichemtktg — 2011-09-06T17:41:40-04:00 — #4
I'm not familiar with console.log(window);.
I didn't see a good candidate on Google's first page of info on console.log(window);. Please recommend a link if possible.
aussiejohn — 2011-09-06T17:29:38-04:00 — #5
https://developer.mozilla.org/En/DOM/Window has a pretty extensive list of properties (though I think quite a few of them are Gecko/Mozilla specific).
If you're using Firefox with [Firebug or Chrome with [URL="http://code.google.com/chrome/devtools/"]Dev tools (Safari has [URL="http://developer.apple.com/technologies/safari/developer-tools.html"]them too](http://getfirebug.com/)) open you can use the following to show the window object in the debug console:
nichemtktg — 2011-09-06T15:37:47-04:00 — #6
Thanks. Can you get a dump of everything in the array for a page? If so how?
felgall — 2011-09-06T15:34:48-04:00 — #7
Yes, with the following exceptions.
The only three properties that don't belong to window are:
The only nine methods that don't belong to window are:
Everything else is a property or method of window and so can use the window['propertyname'] notation to reference it.
nichemtktg — 2011-09-06T11:16:15-04:00 — #8
felgall, are you suggesting that everything in the window DOM can be accessed through array notation?
felgall — 2011-09-06T03:03:04-04:00 — #9
For example the following all reference the same property 'x'.
aussiejohn — 2011-09-06T00:38:30-04:00 — #10
Yup. It's probably easiest if you thing of it in the following (very basic) terms:
- An object is a "hash" array, that can contain multiple properties
- A property is a variable that belongs to an object
- Properties can themselves be objects and in turn have properties inside of them.
aussiejohn — 2011-09-05T23:50:06-04:00 — #11
All properies of the window object are also available in the global scope.
// is analogous to
If you're using Firefox (with Firebug), Chrome or Safari you can do a console.log(window) to show the contents of the window object in your debug console.
mittineague — 2011-09-06T00:25:56-04:00 — #12
Now I see what you mean. eg. from The Window Object
The table below shows the properties, methods, and events supported by the Window object. The entries in the Properties column that include the string (object) are objects in themselves, accessible through the Window object.
So it is both a property and an object. I've learned something myself, though I inagine I'll continue to think of it as an object.
mittineague — 2011-09-05T17:18:10-04:00 — #13
In my own, not very precise terminology:
the "document" is everything, i.e. all tags
the "body" is everything inside the body tags (doesn't include what's inside the head tags)
Both HTML and XML have tags/nodes, so both can have child nodes added to their DOM.
An object can contain other objects, but a property is not the same as an object. Do you have a specific example of what you're referring to?
nichemtktg — 2011-09-05T18:26:17-04:00 — #14
I think what I'm understanding is that the document property of the window object is the same as the document object. What's the advantage of that?
nichemtktg — 2011-09-05T15:54:14-04:00 — #15
Mittineague, I'm still reading. What's the difference between the document object and the document property? If they're the same, why list one as a stand alone object and the other a a property of an object?
nichemtktg — 2011-09-05T15:02:36-04:00 — #16
I'm learning JS and just need to be absolutely certain that I know how this function works (I'm using this function purely as a learning tool). Specifically, I haven't found the documentation that's explicit about how "body" gets justified for inclusion in "document.body.appendChild(nwdiv);".
Working backwards, I found appendChild() in both the html dom & xml dom (I think it's from the html dom, but won't bet the house on that). Anyway, there must be a straight-forward definition of what "document.body" stands for, I'd just like to know exactly where the reference is that spells it out? Someone has to have something like that that's on a page or two. Do you have a link for something like that?
mittineague — 2011-09-05T14:32:31-04:00 — #17
I would add the text before appending the div, but maybe that makes little difference?
Have you tried the code to see what it does?
Which of those do you not understand? Or am I missing your question?