Faqts : Business : Programming : Shopping For You : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

52 of 105 people (50%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can i position prompt in the center of the page

Apr 6th, 2008 18:42
ha mo, Colin Fraser, vempati suresh,


Unlike VB, JavaScript does not give you a lot of control over prompts
and alerts.
To continue from that a bit further, you may also want to try something
like this: 
<script> 
var right=((screen.availWidth/2)+10px);
var top= ((screen.availHeight/2)-10px);
var bottom=((screen.availHeight/2)+10px);
var left=((screen.availWidth/2)-10px);
//all this calculates where the layer is placed
document.write("<div
style='position:absolute;clip:rect("+top+","+right+","+bottom+",
"+left+")'>");
document.write("<form>");
document.write("<input type = 'button' value = 'You make booboo?'
onClick='javaScript:null()'");
document.write("</form>"); 
document.write("</div>");
</script>
This should work on all browsers..but dont count on it... In IE you may
care to use screen.innerWidth  and screen.innerHeight, but the above
should work.
Good luck.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com