PDA

View Full Version : NN6.1 bad createElement support?


simu
08.04.2002, 08:05
I have a problem in NN6.1 with my new page (www.endlessx.com), the page has only the content hardcoded in, and the I check for this:
<pre id=code><font face=courier size=2 id=code>
var check=( !degrade &&
document.createElement &&
document.createTextNode &&
document.getElementById &&
document.getElementsByTagName &&
document.getElementsByTagName( "head" )[ 0 ] &&
document.getElementsByTagName( "body" )[ 0 ] &&
document.getElementsByTagName( "body" )[ 0 ].appendChild &&
document.getElementsByTagName( "body" )[ 0 ].getAttribute &&
document.getElementsByTagName( "body" )[ 0 ].setAttribute &&
document.getElementsByTagName( "body" )[ 0 ].replaceChild &&
document.getElementsByTagName( "body" )[ 0 ].removeChild &&
document.getElementsByTagName( "body" )[ 0 ].firstChild &&
document.getElementsByTagName( "body" )[ 0 ].lastChild );
</font id=code></pre id=code>

and if it's all supported a new stylesheet and js-file is added, in which some new Elements are created, and that's where the problem lies... in Netscape6.1 noone of these Elements are displayed?!

I did some tests with Element creating in NN6.1 and they worked, only the setAttribute-methode with className didn't work well.

does someone know of this issue?

thanks in advance

~ <font color=orange>Simon Käser</font id=orange>
~ [url:mw0cucjtp6]mailto:admin@endlessX.com[/url:mw0cucjtp6]
~ [url:mw0cucjtp6]http://www.endlessX.com[/url:mw0cucjtp6] coming soon

paul
08.04.2002, 08:25
There is no className attribute specified in HTML or XHTML for any element. If you are using the setAttribute method you have to use the name of the attribute you are setting.

<pre id=code><font face=courier size=2 id=code>Element.setAttribute("class","foo");</font id=code></pre id=code>

simu
08.04.2002, 10:15
thanks paul,

I'm now creating the elements like that:

<pre id=code><font face=courier size=2 id=code>
var loa=document.createElement( 'div' );
loa.setAttribute( 'id' , 'loading' );
loa.className='loading';
document.getElementsByTagName( 'body' )[ 0 ].appendChild( loa );
</font id=code></pre id=code>

I don't use setAttribute('class', 'loading'), cos' it doesn't work in IE... strange

but this also doesn't work in NN6.1

you can have a look at the source of the elm_creating-file: www.endlessx.com/elm_creating.txt

thanks

~ <font color=orange>Simon Käser</font id=orange>
~ [url:i6mh2r33k4]mailto:admin@endlessX.com[/url:i6mh2r33k4]
~ [url:i6mh2r33k4]http://www.endlessX.com[/url:i6mh2r33k4] coming soon

Chris
08.04.2002, 17:47
what's the className for??

do what Paul said:

<pre id=code><font face=courier size=2 id=code>
loa.setAttribute("class","loading")
</font id=code></pre id=code>

which version of IE were you testing the code in?? and also, what are you using the class attribute for? if you are just using it to reference the element in a stylesheet, i have found that it doesn't work in IE6... so i use the ID attribute (which does).

//-------------{[url="http://chrispoole.com"]Chris Poole[/url:n8zwku05nz]}-------------//
the artist formerly known as fo3nix

Edited by - Chris on 08/04/2002 21:49:21

Brian Nickel
08.04.2002, 18:08
IE requires you to use className to change the class. I think they envisioned something more for class that never got implimented.

<font face='Courier New'><font color=brown>.Brian
It is best to remain silent and be thought a fool than to open your mouth and remove all doubt.</font id=brown></font id='Courier New'>

simu
09.04.2002, 06:00
yeah IE doesn't support setting the class by setAttribute, and that's why I did it the otherway.

but does nobody know why it doesn't work in NN6.1 and 6.2?
I get no errors!

~ <font color=orange>Simon Käser</font id=orange>
~ [url:si5fz6738r]mailto:admin@endlessX.com[/url:si5fz6738r]
~ [url:si5fz6738r]http://www.endlessX.com[/url:si5fz6738r] coming soon

Edited by - simu on 09 Apr 2002 11:00:54

Garrett Smith
09.04.2002, 08:36
Here's the deal:

1) id is READONLY. If you set an ID, you can't change it.

2) IE requires the js property name as a param. You have to use the exact case, too.

For example,
t = document.createElement("table");
t.setAttribute("cellspacing","0");

should work fine, right?
Not in IE. In IE, you must use

t.setAttribute("cellSpacing","0");

This is because in IE, it is the same thing as using:

t.cellSpacing = "0";

You can't use an actual attribute name, you have to use the js property name that represents that attribute.

IE will interpret cellspacing as a user-defined attribute, so the page won't reflect that.


http://dhtmlkitchen.com/

Edited by - Garrett Smith on 04/09/2002 007:38:30

simu
09.04.2002, 09:26
thanks Garrett,

is the 'id' readonly after I set it with setAttribute or can I not set it?

shall I try to use 'name' instead of 'id', but this is, as I know, not allowed in IE5.

I'm only using the 'id' attribute and the 'className'-thingy so your second tip won't help.

~ <font color=orange>Simon Käser</font id=orange>
~ [url:1w2yw4lk7l]mailto:admin@endlessX.com[/url:1w2yw4lk7l]
~ [url:1w2yw4lk7l]http://www.endlessX.com[/url:1w2yw4lk7l] coming soon