开发者

HTML element type change on onclick and onfocus not working in IE Browsers

i am using below codes for changing the type of HTML element during onclick and onfocus.

function ChangeToPassField() {

   document.getElementById('password').type="password";
   document.getElementById('password').focus();

}

<input type="tex开发者_开发技巧t" name="password" id="password" onblur="ChangeToTextField(); if (this.value == '') {this.value = 'Password';}" onclick="ChangeToPassField(); if (this.value == 'Password') { this.value = ''; } else { this.value; }" onfocus="if (this.value == 'Password') { this.value=''; }; this.type='password';" value="Password" style="width:230px; height:25px; margin-left:5px; background:none; border:0px;" />

the event onclick and onfocus not working IE7 and IE8.it displays the error like

"Could not get the type property: This command is not supported"

How can i Solve this?


The type attribute cannot be changed in Internet Explorer (see the "Remarks" section). You could get around this by replacing the input element with a new one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜