A question please

Discussion in 'HTML' started by Peter, Dec 10, 2006.

  1. Peter

    Peter Guest

    I'm new at this stuff -- so this is probably an incredibly dopey, newby
    question. Please bear with me. I don't know if it's a HTML or javascript
    question. (Or, if a different area altogether, please steer me to the right
    group.)

    I can view the members of the "window" object with the following javascript.
    It returns all the methods, properties, events, etc.

    <script type="text/javascript">
    for(i in window)
    {
    window.document.write(i + "<br />");
    }
    </script>


    I can do the same thing for the "document" object by changing the expression
    to read...

    <script type="text/javascript">
    for(i in window.document)
    {
    window.document.write(i + "<br />");
    }
    </script>


    And then I can check out an individual property, (example "protocol"), with
    the following. It returns "HyperText Transfer Protocol".

    <script type="text/javascript">
    window.document.write(window.document.protocol);
    </script>


    So far, so good....

    But -- I can't find a way to address the "html" or the "head" objects. I
    know they're HTML elements, (<html>, <head>), but they also exist as objects
    because I see on reference sites that they have methods, properties, events,
    etc. So they've got to be child objects of some other object higher in the
    hierarchy. Right? And there has to be some way to address them. Right?

    For instance -- on the MSDN site, the docs say that the "innerText" property
    of the "html" object, "Sets or retrieves the text between the start and end
    tags of the object." OK -- using javascript, how do I "set" or "retrieve"
    that property?

    "window.html.innerText" doesn't work. Neither does
    "window.document.hml.innerText". Is there an object higher than the window
    object that "html" object is a child of?

    Any help greatly appreciated. I've been staring at this *^#(%^ monitor for
    about 8 hours now and my eyeballs are aching.
     
    Peter, Dec 10, 2006
    #1
    1. Advertising

  2. Peter wrote:

    > But -- I can't find a way to address the "html" or the "head" objects. I
    > know they're HTML elements, (<html>, <head>), but they also exist as objects
    > because I see on reference sites that they have methods, properties, events,
    > etc. So they've got to be child objects of some other object higher in the
    > hierarchy. Right? And there has to be some way to address them. Right?



    This works for me in Opera 9

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>untitled</title>
    </head>
    <body>
    <script type="text/javascript">
    var html = document.getElementsByTagName('html')[0];
    for (var p in html) {
    document.write(p+'<br>');
    }
    </script>
    </body>
    </html>



    > For instance -- on the MSDN site, the docs say that the "innerText" property
    > of the "html" object, "Sets or retrieves the text between the start and end
    > tags of the object." OK -- using javascript, how do I "set" or "retrieve"
    > that property?


    This works for me in Opera 9 to see the innerHTML. I don't know when
    setting the innerHTML of the html element would be a good idea.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>untitled</title>
    <script type="text/javascript">
    window.onload=function() {
    alert(document.getElementsByTagName('html')[0].innerHTML);
    };
    </script>
    </head>
    <body>
    </body>
    </html>


    - Peter
     
    Peter Michaux, Dec 10, 2006
    #2
    1. Advertising

  3. Peter wrote:
    > I'm new at this stuff -- so this is probably an incredibly dopey, newby
    > question. Please bear with me. I don't know if it's a HTML or javascript
    > question. (Or, if a different area altogether, please steer me to the right
    > group.)
    >
    > I can view the members of the "window" object with the following javascript.
    > It returns all the methods, properties, events, etc.
    >
    > <script type="text/javascript">
    > for(i in window)
    > {
    > window.document.write(i + "<br />");
    > }
    > </script>
    >
    >
    > I can do the same thing for the "document" object by changing the expression
    > to read...
    >
    > <script type="text/javascript">
    > for(i in window.document)
    > {
    > window.document.write(i + "<br />");
    > }
    > </script>
    >
    >
    > And then I can check out an individual property, (example "protocol"), with
    > the following. It returns "HyperText Transfer Protocol".
    >
    > <script type="text/javascript">
    > window.document.write(window.document.protocol);
    > </script>
    >
    >
    > So far, so good....
    >
    > But -- I can't find a way to address the "html" or the "head" objects. I
    > know they're HTML elements, (<html>, <head>), but they also exist as objects
    > because I see on reference sites that they have methods, properties, events,
    > etc. So they've got to be child objects of some other object higher in the
    > hierarchy. Right? And there has to be some way to address them. Right?
    >
    > For instance -- on the MSDN site, the docs say that the "innerText" property
    > of the "html" object, "Sets or retrieves the text between the start and end
    > tags of the object." OK -- using javascript, how do I "set" or "retrieve"
    > that property?
    >
    > "window.html.innerText" doesn't work. Neither does
    > "window.document.hml.innerText". Is there an object higher than the window
    > object that "html" object is a child of?
    >
    > Any help greatly appreciated. I've been staring at this *^#(%^ monitor for
    > about 8 hours now and my eyeballs are aching.
    >
    >

    1 Download a copy of Firefox.

    2 Install with the "Custom Install" option to mark sure DOM Inspector is
    checked

    3 Or better yet, install the Web Developers Bar extension
    https://addons.mozilla.org/firefox/60/

    4 Open a web page and use the DOM Inspector to traverse the document
    tree and view all the attributes.

    An indispensable "learning|debugging" tool


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 10, 2006
    #3
  4. Jonathan N. Little wrote:
    > Peter wrote:


    > > But -- I can't find a way to address the "html" or the "head" objects. I
    > > know they're HTML elements, (<html>, <head>), but they also exist as objects
    > > because I see on reference sites that they have methods, properties, events,
    > > etc. So they've got to be child objects of some other object higher in the
    > > hierarchy. Right? And there has to be some way to address them. Right?

    >
    > 1 Download a copy of Firefox.
    >
    > 2 Install with the "Custom Install" option to mark sure DOM Inspector is
    > checked
    >
    > 3 Or better yet, install the Web Developers Bar extension
    > https://addons.mozilla.org/firefox/60/
    >
    > 4 Open a web page and use the DOM Inspector to traverse the document
    > tree and view all the attributes.


    Or maybe even better than the DOM inspector is the
    http://getfirebug.com plugin.

    Peter
     
    Peter Michaux, Dec 10, 2006
    #4
  5. Peter Michaux wrote:

    > Or maybe even better than the DOM inspector is the
    > http://getfirebug.com plugin.


    Hmmm, looks interesting. Ain't innovation great! Support "Open Source".

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 10, 2006
    #5
  6. Peter

    Peter Guest

    "Peter Michaux" <> wrote in message
    news:...
    > Peter wrote:
    >
    >> But -- I can't find a way to address the "html" or the "head" objects. I
    >> know they're HTML elements, (<html>, <head>), but they also exist as
    >> objects
    >> because I see on reference sites that they have methods, properties,
    >> events,
    >> etc. So they've got to be child objects of some other object higher in
    >> the
    >> hierarchy. Right? And there has to be some way to address them. Right?

    >
    >
    > This works for me in Opera 9
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    > <html lang="en">
    > <head>
    > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    > <title>untitled</title>
    > </head>
    > <body>
    > <script type="text/javascript">
    > var html = document.getElementsByTagName('html')[0];
    > for (var p in html) {
    > document.write(p+'<br>');
    > }
    > </script>
    > </body>
    > </html>
    >
    >
    >
    >> For instance -- on the MSDN site, the docs say that the "innerText"
    >> property
    >> of the "html" object, "Sets or retrieves the text between the start and
    >> end
    >> tags of the object." OK -- using javascript, how do I "set" or "retrieve"
    >> that property?

    >
    > This works for me in Opera 9 to see the innerHTML. I don't know when
    > setting the innerHTML of the html element would be a good idea.
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    > <html lang="en">
    > <head>
    > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    > <title>untitled</title>
    > <script type="text/javascript">
    > window.onload=function() {
    > alert(document.getElementsByTagName('html')[0].innerHTML);
    > };
    > </script>
    > </head>
    > <body>
    > </body>
    > </html>
    >
    >
    > - Peter



    Thanks. That works. Now I can get in and look around.

    >> I don't know when setting the innerHTML of the
    >> html element would be a good idea.


    LOL. I guess I picked an extreme example. You're right -- I doubt I'd ever
    have a reason to change that specific property.
     
    Peter, Dec 10, 2006
    #6
  7. Peter

    Peter Guest

    "Jonathan N. Little" <> wrote in message
    news:3394$457c3107$40cba7a4$...
    > Peter wrote:
    >> I'm new at this stuff -- so this is probably an incredibly dopey, newby
    >> question. Please bear with me. I don't know if it's a HTML or javascript
    >> question. (Or, if a different area altogether, please steer me to the
    >> right group.)
    >>
    >> I can view the members of the "window" object with the following
    >> javascript. It returns all the methods, properties, events, etc.
    >>
    >> <script type="text/javascript">
    >> for(i in window)
    >> {
    >> window.document.write(i + "<br />");
    >> }
    >> </script>
    >>
    >>
    >> I can do the same thing for the "document" object by changing the
    >> expression to read...
    >>
    >> <script type="text/javascript">
    >> for(i in window.document)
    >> {
    >> window.document.write(i + "<br />");
    >> }
    >> </script>
    >>
    >>
    >> And then I can check out an individual property, (example "protocol"),
    >> with the following. It returns "HyperText Transfer Protocol".
    >>
    >> <script type="text/javascript">
    >> window.document.write(window.document.protocol);
    >> </script>
    >>
    >>
    >> So far, so good....
    >>
    >> But -- I can't find a way to address the "html" or the "head" objects. I
    >> know they're HTML elements, (<html>, <head>), but they also exist as
    >> objects because I see on reference sites that they have methods,
    >> properties, events, etc. So they've got to be child objects of some other
    >> object higher in the hierarchy. Right? And there has to be some way to
    >> address them. Right?
    >>
    >> For instance -- on the MSDN site, the docs say that the "innerText"
    >> property of the "html" object, "Sets or retrieves the text between the
    >> start and end tags of the object." OK -- using javascript, how do I "set"
    >> or "retrieve" that property?
    >>
    >> "window.html.innerText" doesn't work. Neither does
    >> "window.document.hml.innerText". Is there an object higher than the
    >> window object that "html" object is a child of?
    >>
    >> Any help greatly appreciated. I've been staring at this *^#(%^ monitor
    >> for about 8 hours now and my eyeballs are aching.
    >>
    >>

    > 1 Download a copy of Firefox.
    >
    > 2 Install with the "Custom Install" option to mark sure DOM Inspector is
    > checked
    >
    > 3 Or better yet, install the Web Developers Bar extension
    > https://addons.mozilla.org/firefox/60/
    >
    > 4 Open a web page and use the DOM Inspector to traverse the document tree
    > and view all the attributes.
    >
    > An indispensable "learning|debugging" tool
    >
    >
    > --
    > Take care,
    >
    > Jonathan
    > -------------------
    > LITTLE WORKS STUDIO
    > http://www.LittleWorksStudio.com



    Great tip. Thank you. When I got thrown into web development about a month
    ago, I installed IE, Firefox, Opera and Netscape to do cross-browser
    debugging. After checking out the Firefox DOM Inspector, I find that the
    other three also have DOM inspectors. I haven't had a chance to look at them
    all yet. This will keep me busy for weeks. :)
     
    Peter, Dec 10, 2006
    #7
  8. Jonathan N. Little wrote:
    > Peter Michaux wrote:
    >
    > > Or maybe even better than the DOM inspector is the
    > > http://getfirebug.com plugin.

    >
    > Hmmm, looks interesting. Ain't innovation great! Support "Open Source".


    Firebug saves me a lot of time and I sent some money. I hope others do
    to and keep it alive for a long time.

    Peter
     
    Peter Michaux, Dec 10, 2006
    #8
  9. Peter wrote:
    >
    > Great tip. Thank you. When I got thrown into web development about a month
    > ago, I installed IE, Firefox, Opera and Netscape to do cross-browser
    > debugging.


    This is multi-browser debugging which is the practical approach but I
    think your list needs Safari as it is distributed as the default
    browser on all Macs. Safari has it's own set of oddities.

    Peter
     
    Peter Michaux, Dec 10, 2006
    #9
  10. Peter

    Peter Guest

    "Peter Michaux" <> wrote in message
    news:...
    > Peter wrote:
    >>
    >> Great tip. Thank you. When I got thrown into web development about a
    >> month
    >> ago, I installed IE, Firefox, Opera and Netscape to do cross-browser
    >> debugging.

    >
    > This is multi-browser debugging which is the practical approach but I
    > think your list needs Safari as it is distributed as the default
    > browser on all Macs. Safari has it's own set of oddities.
    >
    > Peter


    Is Safari available in a Windows version? I don't have a Mac available. I
    checked the downloads at apple.com but didn't find anything.
     
    Peter, Dec 10, 2006
    #10
  11. Peter

    dorayme Guest

    In article <SC_eh.4630$>,
    "Peter" <> wrote:

    > Is Safari available in a Windows version?


    Don't be silly!

    --
    dorayme
     
    dorayme, Dec 10, 2006
    #11
  12. Peter wrote:
    > "Peter Michaux" <> wrote in message
    >
    > Is Safari available in a Windows version? I don't have a Mac available. I
    > checked the downloads at apple.com but didn't find anything.


    Unfortunately no and decent versions of IE aren't available for Mac. So
    to develop for the mainstream part of the web you need OS X and
    Windows. An Intel-based Mac with Parallels Desktop can do both but it
    is a little bit of a pain still. At least you can tell your boss you
    _need_ a fancy new MacBook Pro or the website might not work for many
    people.

    Peter
     
    Peter Michaux, Dec 10, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    551
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    664
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,799
    Mike Hewson
    Jan 7, 2005
  4. Angelo
    Replies:
    1
    Views:
    316
    Angelo
    May 10, 2007
  5. mera
    Replies:
    7
    Views:
    1,141
Loading...

Share This Page