Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    replaceNode() error in FF

    The script:
    Code:
    function toPassword(oInput) {
    			 var newEl = document.createElement('input');
    			 newEl.setAttribute('type', 'password');
    			 newEl.setAttribute('name', 'pw');
    			  newEl.setAttribute('id', 'pw');
    			 newEl.setAttribute('value', '');
    			 newEl.setAttribute('maxlength', '16');
    			 oInput.replaceNode(newEl);
    			 toPassword.el = newEl;
    			 setTimeout('toPassword.el.focus()',100);
    			 return true;
    		}
    ( From This Thread )

    Here is my form:
    Code:
    <form action="login.php" method="post" id="login">
    			<input type="text" name="un" id="un" value="username" maxlength="45" onFocus="if(this.value=='username'){this.value='';}" />
    			<input type="text" name="pw" id="pw" value="password" maxlength="16" onFocus="if(this.value=='password'){this.value=''; toPassword(this);}" />
    			<input type="image" src="images/layout/login_submit.gif" name="submit" id="submit" value="LOGIN" />
    		</form>
    When i run this in IE, it works great. In FF, i get an error: oInput.replaceNode is not a function.

    For a bit of history on this, I tried simply doing a [object].type='password'. This works in Firefox, but it prevented by security measures in IE. So for those who might suggest that, that won't work here.

    How can i get rid of the function does not exist error?
    Thank you.
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, one way would be to use a function that exists instead

    replaceNode is an iew proprietary thing. The DOM way of doing it is:
    Code:
    oldChild.parentNode.replaceChild(newChild,oldChild)
    And documentation can be found here: Node.prototype.repaceChild
    Last edited by liorean; 01-15-2007 at 06:20 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Thank you very much.
    If I'm postin here, I NEED YOUR HELP!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •