2011-09-04 86 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