Posted by: techGuy November 11, 2008
prompt method's alignment to center in javascript!
Login in to Rate this Post:     0       ?        

Hey LD, I dont know too much of UI side but i'm not sure if window.prompt will do the trick, coz both prompt and window.prompt takes the same argument, i'm not even sure if they are different. You might have to use window.open and use html tags to generate something like prompt. window.open allows you align that window. May be something like this

<body>
<script type ="text/javascript">
 
 
  var prmpt=window.open("","test","height=100,width=400,left=150,top=80");
   prmpt.document.write("<body bgcolor=#CCCCCC>");
   prmpt.document.write("Please enter your name<br>");
   prmpt.document.write("<input type='text' id='lastName'>");
   prmpt.document.write("<input id='val' type=button value='Okay' onclick='opener.test()'>");
   prmpt.document.write("</body>");

  
  function test()
 {
  
   var lastnameField=prmpt.document.getElementById('lastName');
   alert("Last name is "+  lastnameField.value);
   prmpt.close();
  
  }
 
   </script>
</body>

This is the o/p, tested it on IE.

 

 

There could be better ideas from UI genious. This is all i could think of now.

Read Full Discussion Thread for this article