I\'m writing a bookmarklet and I need to be able to prompt the user for a \"password\". However, I don\'t want it to be in clear text on screen, so I cannot use prompt.
there isn't one - try looking into Thickbox on a modal setting like this:
<a href="iframeModal.html?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=200&width=300&modal=true" title="add a caption to title attribute / or leave blank" class="thickbox">Open iFrame Modal</a>
The easy, fast answer: No, there are no cross browser method like window.prompt() that masks the user input. There are however some proprietary stuff you could look into. In MSIE you got window.createPopup(), window.showModalDialog() and window.showModelessDialog(). However I don´t reccomend using this approach =P
What would happen if you used http authentication for your destination? Would the UA prompt the user with a un/pw?
You can create a floating div on the current page, with a form containing a password field.
alternative: let the bookmarlet point to a particular web page. Get the password from the user on that page, and continue.
This solution does not use javascript at all, as you may have noticed. If you really insist on using javascript, you will have to create a new window using javascript (window.open
), add form
and input
elements to it, and set the form's submit
value to your web app backend.
you can of course, display a dialog box on the current page, but that will be pretty irritating to the user. Be warned.
jrh