admin管理员组

文章数量:1287630

I know that we can use these line of codes as below to pass a password to main window in html:

var password ;  
password = prompt('<fmt:message key="ipack.delete.password"/>',''); 
if (password){
    document.location = link+ "&pw="+password;
}

But, the problem is that if I use "prompt", the input field to type password will not be rendered such as password input. I want to hide the characters in password like **. Could you please help me to solve it?

Thanks a lot,

I know that we can use these line of codes as below to pass a password to main window in html:

var password ;  
password = prompt('<fmt:message key="ipack.delete.password"/>',''); 
if (password){
    document.location = link+ "&pw="+password;
}

But, the problem is that if I use "prompt", the input field to type password will not be rendered such as password input. I want to hide the characters in password like **. Could you please help me to solve it?

Thanks a lot,

Share Improve this question asked Jul 5, 2013 at 2:35 hoang nguyenhoang nguyen 2,2195 gold badges22 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Here is a Demo of how you could proceed for a custom popup & get the password:

HTML:

<div id="popup">
    <div>Enter Password:</div>
    <input id="pass" type="password"/>
    <button onclick="done()">Done</button>    
</div>
<button onclick="showPopup()">Show Popup</button>

STYLE:

#popup {
    width:160px;
    height:80px;
    padding:20px;
    background-color:gray;    
    position:absolute;
    top:100px;
    left:100px;
    display:none;
}

SCRIPT:

function done() { 
    document.getElementById("popup").style.display = "none";
    var password = document.getElementById("pass").value;

    //DO STUFF WITH PASSWORD HERE
};

function showPopup() {
     document.getElementById("popup").style.display = "block";
}

本文标签: javascriptHow to write a popup window to pass the password to main windowStack Overflow