link to open window - How to open it centered on the screen ?

I have the code below which I use to open a window. It usually opens on the upper left corner.
How can I open it in the center of the user's screen ?

<a href="javascript:;" onClick="MM_openBrWindow('forms_bridgecallblank.asp','form','scrollbars=yes,resizable=yes,width=1000,height=800')"><i class=" btn btn-white btn-sm fa fa-eye"></i></a>

Open in new window

LVL 1
AleksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Try the following function to center your dialog:

function MyPopUpWin(url, width, height) {
    var leftPosition, topPosition;
    //Allow for borders.
    leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
    //Allow for title and status bars.
    topPosition = (window.screen.height / 2) - ((height / 2) + 50);
    //Open the window.
    window.open(url, "Window2",
    "status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
    + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY="
    + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
}

Open in new window


Then call the function like so:

<a href="javascript:;" onClick="MyPopUpWin('forms_bridgecallblank.asp',1000, 800)"><i class=" btn btn-white btn-sm fa fa-eye"></i></a>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Thanks. I will give it a try tonight.
0
AleksAuthor Commented:
There seems to be some kind of typo in the function.:

Microsoft VBScript compilation  error '800a0408' 

Invalid character 

/bluedot/Intranet/Tools/blankforms.asp, line 44 
function MyPopUpWin(url, width, height) {
----------------------------------------^

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
What's line 44?
0
AleksAuthor Commented:
<% function MyPopUpWin(url, width, height) {
0
AleksAuthor Commented:
nevermind .. :$ ... got it  :)
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Put the function in your Javascript block, not in a server side block
0
AleksAuthor Commented:
Perfect !
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Glad I could be of help :)
0
AleksAuthor Commented:
You always do.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.