Strange behavior in IE6 with the DOM

R

RobG

Frederik said:
I have a script that shows an absolute positioned div where a user can
select the time in a calendar.

The script works perfect in Firefox but in IE6 only my test text node
shows up, not any of the tables.

The page http://demo.patch.dk/test.php show a working example click the
button to show the div.
The script http://demo.patch.dk/plugin/Js/time.js

Any idea what could cause this?

/Frederik Sørensen

I didn't wade through all your code, but it seems you may be adding
your 'tr' elements to the table, not the tbody.

tbody elements are mandatory, but since they are nearly never created
in the HTML, browsers insert them where appropriate. When adding
rows to a table element, Geko browsers assume you meant to add them
to the tbody and so they do that. IE just does nothing.

The solution is to add rows to the tbody, either code a tbody in your
HTML and give it an id so you can find it explicitly, or go down the
DOM from your table element to the tbody and go from there.
 
R

RobG

RobG said:
I didn't wade through all your code, but it seems you may be adding
your 'tr' elements to the table, not the tbody.

tbody elements are mandatory, but since they are nearly never created
in the HTML, browsers insert them where appropriate. When adding
rows to a table element, Geko browsers assume you meant to add them
to the tbody and so they do that. IE just does nothing.

The solution is to add rows to the tbody, either code a tbody in your
HTML and give it an id so you can find it explicitly, or go down the
DOM from your table element to the tbody and go from there.

Ah, just found it:

var tableHour = document.createElement('table');
...
var tableHourRow = document.createElement('tr');
...
tableHour.appendChild(tableHourRow);

Create a tbody, append it to the table element then append your rows
to the tbody.
 
F

Frederik Sørensen

RobG said:
Create a tbody, append it to the table element then append your rows
to the tbody.

That fixed it but i ran into another problem.

All my tmp.setAttribute('style', 'background:blue;'); calls is totaly
ignored by IE6
same with all my tmpLink.setAttribute('onmouseover',
'g_Time.highliteText(\'min'+i+'\')');

But the tmp.setAttribute('id', 'hour'+i); works fine.

I could set the style by using tmp.style.backgroundColor = 'blue'; aso.
which seems to work fine i both IE and firefox.

But how can i fix the onmouseover/onmouseout problem?

tmpLink.onmouseout = 'g_Time.highliteText(\'min'+i+'\')'; is not working

/Frederik Sørensen
 
M

Michael Winter

Frederik Sørensen wrote:

[problems with setAttribute()]
But the tmp.setAttribute('id', 'hour'+i); works fine.

For HTML documents, I always consider the use of the property
equivalents to be preferable. For instance,

tmp.id = 'hour' + i;
I could set the style by using tmp.style.backgroundColor = 'blue'; [...]

Either that or

tmp.style.setProperty('background-color', 'blue', '');

I tend to use the former.
But how can i fix the onmouseover/onmouseout problem?

tmpLink.onmouseout = 'g_Time.highliteText(\'min'+i+'\')'; is not working

The event properties expect function objects, not strings. The solution
in this case should be:

tmpLink.onmouseout
= new Function("g_Time.highliteText('min" + i + "');");



Instead of writing

Time<identifier> = function(/* ... */) {
/* ... */
};
TimeSelecter.prototype.<identifier> = Time<identifier>;

why not just write:

TimeSelecter.prototype.<identifier> = function(/* ... */) {
/* ... */
};

As far as I can see, none of these interim functions are used directly,
so why clutter the global object with identifiers that aren't necessary?

A point of very little concern: selecter isn't a word in the English
language (as far as I know). Selector is. :)

Mike
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Wed, 27 Apr 2005 12:56:11, seen in
Michael Winter said:
A point of very little concern: selecter isn't a word in the English
language (as far as I know). Selector is. :)

True : but it may be in the Danish language.

But I find that there's advantage in using unconventional spellings in
code; they are less likely to clash with forgotten extant identifiers,
and one can scan pages for them without being troubled by the word being
rightly used in text.
 
M

Michael Winter

JRS: In article <[email protected]>,
dated Wed, 27 Apr 2005 12:56:11, seen in
Michael Winter said:
A point of very little concern: selecter isn't a word in the English
language (as far as I know). [...]

True : but it may be in the Danish language.

For the record, I had considered that, but I don't think it's likely.
But I find that there's advantage in using unconventional spellings in
code; they are less likely to clash with forgotten extant identifiers [...]

Though one should weigh that against resulting spelling mistakes.
Conventional has it's own benefits, too.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top