tags:

views:

81

answers:

3

I would like to prompt the user for some input on a webpage.

I can't use the builtin Javascript prompt function as it is creates security warnings in IE.

Is there a best practice/method/example that people use to recreate this?

The Javascript would need to be embedded in the page, so I'm looking at avoiding weighty external libraries.

+1  A: 

I'd steer away from prompts; they're obtrusive. You could render a form.

Johannes Gorset
+1, render a form: http://computer.howstuffworks.com/question369.htm
Rubens Farias
This is basically what the OP said: He doesn't want to use prompt.
T.J. Crowder
@T.J. Crowder: It's not "basically what the OP said"; he's asking for an example of how to mimic a prompt, and the answer provides it.
Johannes Gorset
+4  A: 

The easiest, most user-friendly approach would probably be to create a normal HTML form that you show with JavaScript in response to a click event on a link or button; you'd then hide the form after the data has been submitted.

Ian Oxley
@OP: When showing the form, you can even position it absolutely in the middle of the viewport (`position: absolute` and `left` and `top` styles), on top of other content (`z-index` style), with an iframe shim underneath it to prevent clicks anywhere outside the form. More on iframe shims here: http://www.macridesweb.com/oltest/IframeShim.html
T.J. Crowder
You should render the form with JavaScript, too.
Johannes Gorset
A: 

I use jQuery plugin Impromptu. It's nice and unobtrusive and sufficiently lightweight.

Eugene Morozov