2011-09-04 85 views
3

我使用jQuery来使从文本到焦点密码类型的输入字段开关。这段代码在Chrome中运行正常,但是当我尝试在IE 8中使用它时,它只是完全删除了该字段。 IE 8返回此错误:JQuery的IE问题

This command is not supported. 
jquery.min.js 
Line: 16 
Char: 26827 

这里是我使用的HTML代码:

<div id="reg_passdiv" style="margin-bottom: 5px;"> 
<input name="reg_pass" class="inputbar italic" type="text" value="Password..." onfocus="if ($(this).attr('class') == 'inputbar italic') { $(this).attr('class', 'inputbar reg'); $(this).detach().attr('type', 'password').appendTo('#reg_passdiv'); this.value = ''; $(this).focus(); }" onblur="if (this.value == '') { $(this).attr('class', 'inputbar italic'); $(this).detach().attr('type', 'text').appendTo('#reg_passdiv'); this.value = 'Password...'; }" spellcheck="false"> 
</div> 

任何人都可以向我解释,我怎么能修复这个bug?谢谢!

+0

你试过取出分离()?似乎没有必要为你只是改变了属性 – Bodman

+0

你不得不使用它,因为你不能改变装配的输入的类型。 – Matt

+0

@Matt,是啊在IE安全问题。 – Bodman

回答

3

这是一个历史问题,您可以在这里深入阅读:http://bugs.jquery.com/ticket/8232。简短的版本是,这在老年人IE浏览器中根本不可行。

的好处是,我关闭该票为“patchwelcome”,所以,如果你认为你可以解决一个合理修复的问题,那么我们更快乐,然后审查和测试。

0

在大多数情况下,这是XML相关的问题。不是DOCTYPE,MIME类型是问题。 更多here

+0

对不起,我的错。您无法更改输入字段的类型。唯一的解决办法是制作两个字段并在两者之间交换数值和属性。只显示()/隐藏()正确的字段。 – atma

+0

是的,我做到了。不管怎么说,多谢拉 :) – Matt