Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the JavaScript prompt?

Tags:

javascript

I am trying to use the JavaScript prompt for entering text that will be enclosed between tags e.g

[url]http://www.yahoo.com[/url]

The problem is that the prompt always appear in the top left corner of the browser.

How do I position such that it only display the prompt around the text area where the text will be entered?

And also how do I customize the JavaScript prompt so that it look more user friendly?

like image 765
Sillicon.Dragons Avatar asked Mar 23 '26 23:03

Sillicon.Dragons


2 Answers

You can't customize that (if you are refering at prompt()). You need to create a pop up window and customize its insides.

like image 147
zozo Avatar answered Mar 26 '26 14:03

zozo


You can't position the JavaScript prompt box, and you'll find it varies between different browsers.

Although you didn't explicitly ask, may I suggest either creating your own prompt (as simple as making a div with an input and positioning absolutely, and setting the display CSS property correctly to "pop" it up and close it, or (and this is what I would do) use something like jQueryUI or a similar alternative that will do what you want.

One final bonus: just insert the [url][/url] tags with a placeholder domain or message imbeteen, and automatically highlight it and give it focus, so that when they start typing it will appear there, inline.

like image 29
LeonardChallis Avatar answered Mar 26 '26 13:03

LeonardChallis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!