views:

2462

answers:

4

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.

Is there a masked alternative to prompt()?

Any other suggestion?

+4  A: 

You can create a floating div on the current page, with a form containing a password field.

Ryan Emerle
Yes. But I feat the possible side effects of modifying arbitrary pages.
Assaf Lavie
I *fear* the side effect...
Assaf Lavie
+2  A: 

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

Here Be Wolves
That's how http://www.instapaper.com does it.
Patrick McElhaney
+1  A: 

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>
Josh
How could I use jQuery in a bookmarklet?
Assaf Lavie
+1  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?

anddoutoi
I really don't like the latency the web server adds. This is the current solution I have and it's what I'm trying to avoid.
Assaf Lavie