IE7中无法识别文本输入readonly属性? [英] Text input readonly attribute not recognized in IE7?

查看:200
本文介绍了IE7中无法识别文本输入readonly属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过javascript设置readonly =readonly(换句话说,是真的):

I am setting readonly="readonly" (in other words, true) via javascript:

document.getElementById("my_id").setAttribute("readonly", "readonly");

这具有预期的效果(使该字段不再可编辑,但其内容随着表格)在FF,Safari和Chrome中,但不适用于IE7。在IE7中,我仍然可以修改文本输入字段的内容。

This is having the intended effect (making the field no longer editable, but its contents are submitted with the form) in FF, Safari and Chrome, but not for IE7. In IE7 I can still modify the contents of the text input field.

我也试过设置(readonly,true),这三个都适用我正在测试的其他浏览器,但IE7也忽略了。

I have tried setting ("readonly", "true") as well, which works in all three other browsers that I am testing, but which IE7 also ignores.

有没有人有尝试用IE7做这个的经验?我不想使用disabled属性,因为我希望文本输入字段中的值与表单一起提交。

Does anyone have experience with trying to do this with IE7? I do not want to use the disabled attribute as I want the value within the text input field to be submitted with the form.

推荐答案

你试过这个吗?

document.getElementById("my_id").readOnly = true;

这篇关于IE7中无法识别文本输入readonly属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆