|
Posted by Peter on 12/10/06 20:00
"Peter Michaux" <petermichaux@gmail.com> wrote in message
news:1165730145.280812.176370@j72g2000cwa.googlegroups.com...
> 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.
[Back to original message]
|