SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: Javascript in HTML Tables
-
Jul 23, 2002, 14:35 #1
- Join Date
- Jul 2002
- Posts
- 6
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Javascript in HTML Tables
http://www.webreference.com/js/column2/format.html
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???
Block
-
Jul 23, 2002, 14:56 #2
- Join Date
- Nov 2001
- Location
- London, UK
- Posts
- 502
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I assume you are reffering to the last para:
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).
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.
-
Jul 23, 2002, 18:40 #3
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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
-
Jul 23, 2002, 21:01 #4
- Join Date
- Mar 2001
- Location
- northern Maine
- Posts
- 52
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think this had to do with an old NS3(?) bug with document.write()-ing inside a <td>...
-
Jul 24, 2002, 00:56 #5
- Join Date
- Feb 2002
- Location
- Gatwick, UK
- Posts
- 1,206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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
Flawless---=| If you're going to buy a pet - get a Shetland Giraffe |=---
-
Jul 24, 2002, 10:24 #6
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
To be honest i aint one for cross browsability with netscape, but i thought innerHTML was a ie only feature. Then again i think flawless is like me with cross browsability.
-
Jul 24, 2002, 10:49 #7
- Join Date
- Feb 2002
- Location
- Gatwick, UK
- Posts
- 1,206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nope - innerHTML is universal - I believe.
Flawless---=| If you're going to buy a pet - get a Shetland Giraffe |=---
-
Jul 26, 2002, 18:31 #8
- Join Date
- Jan 2002
- Location
- London
- Posts
- 3,509
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Flawless_koder
Nope - innerHTML is universal - I believe.
Flawless
Read up here:
http://www.webreference.com/js/tips/001209.html
http://www.mozilla.org/docs/web-deve...e_2.html#other
However, this is a good guide to the cross-browser alternative:
http://www.pxl8.com/cloneNode.html
Don't give me wrong, I'm leaning towards ignoring NS4 users (!) but because others read and act on these posts I thought it was important to set the record straight!MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
-
Jul 26, 2002, 18:42 #9
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
arr k cheers m@rco, why can't people just upgrade or all developers force people to upgrade as some people dont even know what an upgrade is or how to do it lol, from what i saw the other day
-
Jul 26, 2002, 19:20 #10
- Join Date
- Jan 2002
- Location
- London
- Posts
- 3,509
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Exactly! It's not just to make life easier for us - they benefit from a richer experience at the end of the day.
See another post in this forum for the whole W3C standards conformance shebang! (which I'm 100% behind incidentally, but I'm ultimately forced to target IE in the meantime....)MarcusJT
- former ASP web developer / former SPF "ASP Guru"
- *very* old blog with some useful ASP code
- Please think, Google, and search these forums before posting!
-
Jul 27, 2002, 02:15 #11
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Jul 27, 2002, 02:47 #12
- Join Date
- Feb 2002
- Location
- Gatwick, UK
- Posts
- 1,206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OUCH @ trying to do anything constructive without
innerHTML. I use it often instead of passing
variables around
Flawless---=| If you're going to buy a pet - get a Shetland Giraffe |=---
Bookmarks