gevans Posted January 30, 2009 Share Posted January 30, 2009 OK, here's the javascript; function clearPassField(obj){ var newInput = document.createElement('input'); newInput.setAttribute('type','password'); newInput.setAttribute('name',obj.getAttribute('name')); obj.parentNode.replaceChild(newInput,obj); newInput.focus(); } and here's the two inputs that use it; <input type="text" id="cemail" name="cemail" value="Confirm E-mail Address" onclick="clearField('Confirm E-mail Address', this.id)" onblur="checkField('Confirm E-mail Address', this.value, this.id)" /><br /> <input type="text" id="pass" name="pass" value="Password" onclick="clearPassField(this)" /><br /> Haven't bothere with IE6 yet, but so far IE7 and IE8 don't like it, everything works fine appart from the final focus() which works in Safari, FF2, FF3 etc... Link to comment https://forums.phpfreaks.com/topic/143145-solved-focus-not-working-in-ie/ Share on other sites More sharing options...
landavia Posted January 30, 2009 Share Posted January 30, 2009 this is complicated JS well... how about add var before var newInput = document.createElement('input'); then var newInput; newInput = document.createElement('input'); and i was think this obj.parentNode.replaceChild(newInput,obj); perhaps the problem? Link to comment https://forums.phpfreaks.com/topic/143145-solved-focus-not-working-in-ie/#findComment-750729 Share on other sites More sharing options...
gevans Posted January 30, 2009 Author Share Posted January 30, 2009 That's not the problem, this is working in FF and Safari, it's just an issue with IE and focus() Link to comment https://forums.phpfreaks.com/topic/143145-solved-focus-not-working-in-ie/#findComment-750730 Share on other sites More sharing options...
gevans Posted January 30, 2009 Author Share Posted January 30, 2009 Ok, I've fixed it. IE is such a fussy bastard that it has to wait a second before it can focus, otherwise the element hasn't settled in properly and thinks it doesn't exist. so I changed the line; newInput.focus(); to setTimeout(function() { newInput.focus(); }, 10); Link to comment https://forums.phpfreaks.com/topic/143145-solved-focus-not-working-in-ie/#findComment-750745 Share on other sites More sharing options...
landavia Posted January 30, 2009 Share Posted January 30, 2009 sry.. i mean that problem will have problem on IE and yeah.. that's bastard IE.. i wonder is related to SP 2? Link to comment https://forums.phpfreaks.com/topic/143145-solved-focus-not-working-in-ie/#findComment-750754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.