By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,652 Members | 1,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,652 IT Pros & Developers. It's quick & easy.

Problem removing readOnly in IE

P: n/a
I am having trouble with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
</head>
<body>
<input value='test' type='text' readonly='readonly'
onfocus='this.readOnly = false;'
onblur='this.readOnly = true;'></input>
</body>
</html>

In FF, this works as I would expect. When clicking on the input, the readOnly
property is set to false and the focus is given to the element, with the
cursor placed after the last character.

In IE, the readOnly property is set to false, but the element isn't actually
given focus. Instead, I have to click on the input a second time in order to
actually input text with the keyboard.

Is there a way to make this work the same in IE as it does in FF? I have
tried things like calling this.focus() and this.click() after setting
readOnly to false, but they have no effect.

Any help would be greatly appreciated.

Thank you,

- J.
Dec 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
J. McConnell wrote:
I am having trouble with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
</head>
<body>
<input value='test' type='text' readonly='readonly'
Hi,

Maybe you confused IE because you set the value to 'readonly' instead of the
expected boolean true or false.

And maybe onMouseOver with onMouseOut works better. Giving focus to a
readonly-element possibly made little sense to the IE developers.

Give that a shot.

Regards,
Erwin Moller
onfocus='this.readOnly = false;'
onblur='this.readOnly = true;'></input>
</body>
</html>

In FF, this works as I would expect. When clicking on the input, the
readOnly property is set to false and the focus is given to the element,
with the cursor placed after the last character.

In IE, the readOnly property is set to false, but the element isn't
actually
given focus. Instead, I have to click on the input a second time in order
to actually input text with the keyboard.

Is there a way to make this work the same in IE as it does in FF? I have
tried things like calling this.focus() and this.click() after setting
readOnly to false, but they have no effect.

Any help would be greatly appreciated.

Thank you,

- J.
Dec 1 '06 #2

P: n/a
On 2006-12-01, Erwin Moller
J. McConnell wrote:
>I am having trouble with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
</head>
<body>
<input value='test' type='text' readonly='readonly'

Maybe you confused IE because you set the value to 'readonly' instead of the
expected boolean true or false.
I gave this a shot, setting the value to true or false, and it didn't
make a difference. Anyway, "readonly" is the only valid value in XHTML.
And maybe onMouseOver with onMouseOut works better. Giving focus to a
readonly-element possibly made little sense to the IE developers.
Actually, onMouseOver and onMouseOut did work. Unfortunately, it
doesn't do me any good because you can't tab into the control. Also, I
recently read that one difference between readonly and disabled is that
readonly elements can receive focus while disabled elements can't.

I do agree that this is an edge case and arguably not the best way to go
about this, but do to circumstances beyond my control it would be
difficult to go another route, like never setting the element to
readonly in the first place.

Thanks for the suggestions,

- J.
Dec 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.