473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Whats up with setAttribute on IE

Whats going on with setAttribute on IE it appears to work on some examples
and working code but not on other code that I am writting ?

<style>
.foo {
font-size: 200%;
}
</style>
var e = document.createElement( "div");
e.setAttribute( "class", "foo"); // fails
e.setAttribute( "className", "foo"); // okay
e.setAttribute( "style", "font-size: xx-large"); // fails
e.setAttribute( "style.fontSize", "xx-large"); //fails
e.setAttribute( "style", "font-size: 24pt;"); //fails
e.style.fontSize = '24pt'; // okay
e.className = 'foo'; // okay
e.appendChild( document.createTextNode( "Text Text Text"));
document.body.appendChild( e);

Anyone help fill in the gap in my head !

Many thanks in advance,

Aaron
Feb 10 '07 #1
2 8834
Aaron Gray wrote:
Whats going on with setAttribute on IE it appears to work on some examples
and working code but not on other code that I am writting ?
Don't use setAttribute() for built in attributes, just set the attribute
value.
>
var e = document.createElement( "div");
e.setAttribute( "class", "foo"); // fails
Use e.className.
e.setAttribute( "className", "foo"); // okay
This creates a new attribute.

--
Ian Collins.
Feb 10 '07 #2
VK
On Feb 11, 1:19 am, "Aaron Gray" <ang.use...@gmail.comwrote:
Whats going on with setAttribute on IE it appears to work on some examples
and working code but not on other code that I am writting ?
DOM Tree and DOM interfaces are different things - but there is a
greate confusion on this topic. One of benefits of upcoming HTML 5.0
is that it explains it in details and in proper terms - something that
W3C failed to do in 7 years.
<style>
.foo {
font-size: 200%;
}
</style>

var e = document.createElement( "div");
e.setAttribute( "class", "foo"); // fails
e.setAttribute( "className", "foo"); // okay
e.setAttribute( "style", "font-size: xx-large"); // fails
e.setAttribute( "style.fontSize", "xx-large"); //fails
e.setAttribute( "style", "font-size: 24pt;"); //fails
e.style.fontSize = '24pt'; // okay
e.className = 'foo'; // okay
e.appendChild( document.createTextNode( "Text Text Text"));
document.body.appendChild( e);
function init() {
var elm = document.createElement('div');
elm.appendChild(document.createTextNode('Text'));
elm.className = 'foo';
elm.style.backgroundColor = 'yellow;
document.body.appendChild(elm);
}
window.onload = init;

Feb 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: spaminator | last post by:
I have a script which adds a row. I am using the DOM model to do this. I have an image link which is to be inserted next to a input field in each row i add , how do i do this? I think i have to...
8
by: timmy_dale12 | last post by:
I need help with this one. I have a function that pastes a row. In each row i am pasting a link which is to call a date picker javascript function. This is the code that pastes the link : link =...
3
by: NewmanBT | last post by:
As you can see from the code below, several textboxes will be dynamically created and each will be tied to an org. The ChangeComment function should allow for an update to the database whenever...
3
by: daveland | last post by:
I am working on some JavaScript that dynamically adds rows to a table in response to a button click. A new row does appear on the screen when the button is clicked. However, that table to which a...
6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
4
by: jj6849 | last post by:
I have been using the dom to add a row to my form for awhile now, but now I need to do some validation to make sure certain check boxes aren't checked with other check boxes. Now of course it works...
2
riptide2049
by: riptide2049 | last post by:
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to...
4
by: askalottaqs | last post by:
xml = minidom.Document() # Creates user element userElem = xml.createElement("user") # Set attributes to user element userElem.setAttribute("name", "Sergio Oliveira")...
2
by: murderof1 | last post by:
Hello, I'm new to Javascript, but I'm trying to create html tables based off a checkbox action. Is it possible to do this on the same page? I've noticed that document.write() will create the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.