The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Javascript in HTML Tables

I read on the above tutorial that one should NEVER place a script in an HTML table, especially if it has doument. write in it. Does anyone know why this would be true? I have a date and time script in my HTML table and have no problem with it. Your thoughts???

If you would like to display the date somewhere in an HTML table, you're in trouble. Never embed a script in a table, especially if it has a document.write() statement. At this time there is no workaround for this annoying bug (besides printing the entire table in JavaScript, or using Dynamic HTML).

I am not total sure of what they meant there.. but I put document.write in HTML table and nothings happends... I also use the VB version and still nothing happens... chnaces of somene's browser having problme (seems to me) is next to nothing.

When ever I want to put the current date and time I just simply use the document.wite and it works fine.. I dont know what that person is meant...

I am assuming they are referring to the JS code just above the para, I can see there is problem.. but what if that was put inside a function so we just make a call to the function and it prints out the date as it called.

I think the author has some reason for saying that, which should have been made clear but I dont agree with her/him.

the only thing that document.write would do is if you have it in a onclick event which would clear the screen, but as for that comment, it sounds kind of stupid unless, you put the script in the wrong place like outside a tr or td tag etc, which would simply treat it as a comment tag and print it at the top of the table or something like that.

And in anycase I would use
innerHTML/outerHTML/innerText/outerText
to modify the content if using an event to write to the document, unless you want a clean page of course

I never use document.write - i think it's bad practice unless
you're creating a new window with only one line - and
even then i'd probably just create an object and use, as Andrew quite rightly said, innerHTML/innerText

well as long as standards keep moving the way they are we should have no problem with the damn hassle of cross browsability, what with xhtml(strict) and xml should help people view correctly and not have any hassles with the engines that microsoft or netscape use.