i have a javascript prompt like the following and i would like to bring the prompt center of the screen. How to do this in using javascript?
function showUpdate() {
var x;
var name=prompt("Please enter your name","");
if ( name != null ) {
x="Hello " + name + "! How are you today?";
alert("Input : " + name );
}
}
And this is how i call this :
<a onclick = "showUpdate() " style="vertical-align: middle;" class="parent" href=""><span>5. Missed P/U Comments</span></a>
it works find excepts the prompt goes to the left corner in IE and center in Firefox
but i need to the same solution to work in both the browsers.
The
prompt(andalert) popups are implemented differently depending on the browser you’re using. This is because the popups are browser functionalities, they aren’t JavaScript objects or anything like that. (Just like the console is different for each browser, it depends on the implementation.)If you really want your prompts to be positioned / styled consistently, you’re going to have to build your own prompt.
The easy way out would be to use a library like jQueryUI.
On the other hand, you can just build it yourself: