|
Posted by Peter Michaux on 12/10/06 05:55
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
[Back to original message]
|