Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to display the following Alert message box in the google chrome.
But it's positioning at the top of the page. How can i make it Center to the WebForm. Issue occurred for google chrome. When if im writing that in a separate function in aspx and calling it.. Page is redirecting with out displaying the message.

What I have tried:

In a particular button click event i've written this...

Response.Write("<script>alert('registered successfully')</script>");
Response.Write("<script>window.location.href="/KB/answers/changepwd.aspx";</script>");
Posted
Updated 25-Feb-16 23:28pm
v5
Comments
Sinisa Hajnal 26-Feb-16 4:47am    
You cannot control the position of browser dialog. You could write your own though. Use jQueryUI dialog or any other custom made (or even make your own DIV in which you show the text, wait for couple of seconds and then redirect) - you don't need no stinking pop-up :)
F-ES Sitecore 26-Feb-16 5:00am    
Might as well post this as a solution.
Krunal Rohit 26-Feb-16 5:31am    
Post it as a solution :)

KR
[no name] 26-Feb-16 5:21am    
You couldn't change browser predefined design. It will display at top of the page.

If you need it badly then you need ti implement Custom alert box or jQuery UI.

https://www.developphp.com/video/JavaScript/Custom-Alert-Box-Programming-Tutorial
Krunal Rohit 26-Feb-16 5:35am    
Well, you can't. If you want to center it, you should create your own custom control or rather user the jQuery UI dialog.


KR

1 solution

Normally, display of alert box depends upon the browser you are using. The any kind of message box (alert or prompt) in javascript are displayed at top in google chrome, while they are displayed at center in moz. Firefox and Microsoft edge. If you want to display it anyhow at center location of browsing window independent of browser, then take help of java script.

Get innerwidth and innerheight of browsing window in javascript. Writing some simple calculation, find center location. Now, using popup window, display any kind of message at center location of browsing window.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900