[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: Re: onloading the body, call the document.write, is it ok?
From: Ilya Konstantinov <kfm-devel () future ! galanet ! net>
Date: 2001-08-28 9:44:42
[Download RAW message or body]
On Tue, Aug 28, 2001 at 03:53:38PM +0800, yongsun@email wrote:
> Does the konqueror support those js codes?
>
> <html>
>
> <head>
> <script>
> function testjs()
> {
> document.write("<html><body><p>haha,test js!</body></html>");
Apparently Konqueror cannot add rewrite the document after it finished
rendering. This is a bug in Konqueror, since Netscape 4 and higher can
do it - but you have to add a document.close() statement afterwards.
> }
You forgot the terminating </script>.
> </head>
>
> <body onload=testjs()>
You didn't quote "testjs()".
> </body>
>
> </html>
I've attached some JS code which should do the equivalent of what
you're trying to do using the W3C DOM interface (should work on IE5+,
Netscape 6+, Mozilla, Konqueror - and latest Opera I assume, though
I didn't test).
["test2.html" (text/html)]
<html>
<head>
<script>
function add_some_text()
{
node = document.createTextNode('haha,test js!');
body = document.getElementsByTagName('body').item(0);
body.appendChild(node);
}
function replace_text_n4()
{
document.write("haha,test js!");
document.close(); // this is important in N4
}
function replace_text()
{
// this will remove the old content from inside BODY
body = document.getElementsByTagName('body').item(0);
for(i=0; i<body.childNodes.length; i++) {
body.removeChild(body.childNodes[i]);
}
// this will add the new text
node = document.createTextNode('haha,test js!');
body.appendChild(node);
}
</script>
</head>
<body onload="replace_text()">
hey
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic