Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-28-2003, 01:29 AM   PM User | #1
Vlaad
New Coder

 
Join Date: Mar 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Vlaad is an unknown quantity at this point
readonly attribute

Hello people,

I'm having a niggling difficulty using Internet Explorer, where the following code:
x.setAttribute('readonly','true');
does NOT set the readonly attribute to true.

It's working fine in Mozilla, so I can't really see what the problem is (though I encountered something I'm guessing is pretty much the same in the x.className VS x.setAttribute('class','name') function problem.

It's just a simple problem, but it's annoying the crap out of me.

Please help!

Much appreciated!
__________________
- Vlaad
Vlaad is offline   Reply With Quote
Old 05-28-2003, 01:37 AM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Try using the DOM2 HTML extension:

someElement.readOnly = true;
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 05-29-2003, 11:18 AM   PM User | #3
Zvona
Regular Coder

 
Join Date: May 2002
Location: Helsinki, Finland
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Zvona is an unknown quantity at this point
Another way that should work:

oElement.setAttribute("readonly","readonly");

This is because attribute readonly can have only value "readonly". However, when dealing with booleans and controlling elements solely thru scripting, it's recommended to use the method jkd mentioned.
__________________
Zvona
First Aid for
Web Design
Zvona is offline   Reply With Quote
Old 05-29-2003, 02:54 PM   PM User | #4
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
My experience is that

obj.setAttribute('foo','bar');

often doesn't work in IE, for no reason, whereas

obj.setAttribute('foo','');
obj.foo = 'bar';

is reliable.
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

Last edited by brothercake; 06-06-2003 at 11:00 AM..
brothercake is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:00 PM.


Advertisement
Log in to turn off these ads.