Mark Goda

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromMark Goda
ToMe
Subjectnetscape block reconfigures table cells?
Date28 November 2004 00:42
Good Afternoon-
 
            I have a dynamic sign in page written in php for ie.  The
layout is a basic table, 2 columns by 8 rows.  R1C1 is user id label,
R1C2 is user id form element, etc.  The 7th and 8th row have colspan=2
and style="display:block;", which when the user id form element onkeyup
event occurs hides (.style.display='none';) rows 7 & 8 if no data is
entered.
 
            This works very well in IE6, but in Netscape, using block
seems to destroy the colspan.  The first keyup with data shows text/link
in cell[0].  Press backspace and cells disappear, as expected.  The
second keyup with data appears to shift cells in rows 7 & 8 under the
second column.  Each backspace followed by a character key appears to
shift the text/link one more cell to the right, but an
alert(.cells[0].innerHTML); shows that cell[0] is still the only cell
with code.
            
            If you have a Netscape enabled system, you can see this for
yourself at [test page address].  This is a
stripped version of the real page, however, and seems to push extra rows
on the bottom when swapping key/backspace on the user id form field.  I
am just starting to code for cross-browser, so please excuse the layout
if you view the real page ([page address])
in the next day or two.  Please feel free to view the code if it will
help.
 
            I appreciate your attention and response in advance,
Thank you.
 
Mark Goda.
FromMe
ToMark Goda
SubjectRe: netscape block reconfigures table cells?
Date28 November 2004 16:41
Mark,

This is because IE is stupid (not joking).

Table rows should use display: table-row;
Table cells should use display: table-cell;

IE does not understand either of these, even though they are the correct
values. It expects you to use 'block'. Other browsers that correctly
implement CSS will expect you to use the correct values. This includes
Mozilla/Firefox, Opera, Safari/Konqueror, ICEbrowser. These browsers will
correctly treat 'block' as a block level element, which cannot support
colspan.

If you use the correct values in IE, it will produce an error (see, I told
you it was stupid). So, when you want to change it, use try ... catch (this
way you also avoid the complexities and support problems of using sniffing):

try {
  //standards compliant browsers
  theTD.style.display = 'table-cell';
} catch(e) {
  //IE stupidity
  theTD.style.display = 'block';
}

You can also set display to a blank string:
theTD.style.display = '';
Assuming the initial styles are not set inline, this will work in all of
these browsers, including IE.


Hope this helps

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromMark Goda
ToMe
SubjectRe: netscape block reconfigures table cells?
Date28 November 2004 20:21
Good Afternoon-

	Thank you very much for your assistance.  I feel stupid asking
this, but I have another problem I can't figure out: a cell containing
another table seems to disregard style="text-align:center;" and
align=center, i.e. the table is always left-justified when inside
another tables cell in NS.  Is there a solution, or am I coding
incorrectly.

	Is there an online reference that is explicitly designed for NS
object references and functions, like msdn?  Developer.netscape.com and
devedge no longer seem to be running?

	Again, my thanks.
	Mark Goda.
FromMe
ToMark Goda
SubjectRe: netscape block reconfigures table cells?
Date28 November 2004 21:44
Well once again, this is an IE stupidity. text-align relates to text
(including the text inside the table) but IE misinterprets it, and
align="center" should in fact cascade also. What you need is to use
automatic margins. IE will ignore these, so you can use text-align for IE,
then override it later. Something like this should work:

<td style="text-align:center;">
  <table style="margin-left:auto;margin-right:auto;">
    <tr>
      <td style="text-align:left;">

> Is there an online reference that is explicitly designed for NS

Well, firstly, NS is not the only non-IE browser. There are in fact several
browser types that are currently used engines. The main ones are
Opera
Konqueror/Safari
Mozilla/Firefox/Netscape6+ (Netscape is Mozilla, with AOL branding)
ICEbrowser
IE Mac
IE windows

IE windows is the main one that gets things wrong (see
http://www.howtocreate.co.uk/wrongWithIE/ for more details). All the others
try to follow the standards as best they can. Unfortunately, IE/win is the
most popular, so it needs special treatment for its incorrect rendering.
The best site for the standards is w3c.org since they write them, but in
general, my site and www.quirksmode.org and mozilla.org are good places.
Searching on the internet for 'standards compliant browsers' will get you
some other good results.

Tarquin
FromMark Goda
ToMe
SubjectRe: netscape block reconfigures table cells?
Date28 November 2004 21:45
Good Afternoon-

	I think I owe you my first-born!  Thank you very much.

Mark.
FromMe
ToMark Goda
SubjectRe: appendChild (nodes) do not append to both dhtml display and form
Date12 December 2004 18:02
Good Afternoon-
 
            I have a table which is inside of a form to which I am
adding cells and form elements.  Nodes added to the form do not display
inside table cells.  Nodes added to the table do not register when the
form is submitted.
 
            I have a work around that I do not like.  I create 2
elements, one in the form and one in the table, and set an onKeyUp event
to copy data from the table element to the form element.  This works
well for most elements, but I use fPopCalendar for dates to prevent
invalid date entry that requires an onMouseMove event to constantly
check for date changes.
 
            I have attached the script below.  For clarification, the
table shows 'Para #' in the first cell and a textarea named para# in the
second for each row with the final row holding an 'Add Paragraph' button
and an 'Update' button.  The while loop using np finds the next
paragraph number,  and the nested for(each n in .) loops find the node
before which to insert the new row.
 
            Do you know of a way to insert one element into both a table
and a form at the same time.
 
            Thank you,
            Mark Goda.

[a load of code trying to append a form input to a table]
FromMark Goda
ToMe
SubjectRe: appendChild (nodes) do not append to both dhtml display and form
Date12 December 2004 21:40
Mark,

heh, fun eh?

browsers have real problems handling creation of form elements. some
browsers refuse to create anything except text inputs (IE on Mac and
Konqueror), some don't like radio inputs (IE on Win), some refuse to send
form data to the server (IE on Mac and sometimes safari), some remove them
when commanded to do so but always send them to the server anyway (opera),
and there are probably more problems that I am unaware of. Personally I try
to stay as far away from forms+DOM as possible. However, there are two
things that may help;
1. If you _must_ use DOM to create form inputs;
add the input as a child of the correct element (the TD, for example)
then manually add it into the forms array:
  document.forms['name of the form']['name of input'] = refToNewInput;
2. instead of using DOM methods, use innerHTML. even though this is not
part of the standard, it works better with forms in all DOM browsers
(except with XHTML pages - don't use it with them). Most will add form
elements into both the document and actual form data much more reliably
this way.

If you want to try adding form elements, try taking a look at PPK's
research, it is much more thorough than mine:
http://www.quirksmode.org/dom/domform.html
http://www.quirksmode.org/dom/usableforms.html


Tarquin
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.