• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 960
  • Last Modified:

window.open new window on top and center of screen

When the page loads the new window which pop ups minimize automatically I want it to be there on the top of parent window and on center of the screeen.
0
aksfluent
Asked:
aksfluent
  • 2
  • 2
1 Solution
 
aksfluentAuthor Commented:
Please help me out I tried with alwaysRaise=1 but it works in Netscape but not in IE and Modzilla.
0
 
heronganCommented:
Try it!


<html>

<script language="JavaScript">

function f_OpenWin()
{
 window.open ("http://yahoo.com","","width=200, height=200, top=" + (screen.height-200)/2 + ", left=" + (screen.width-200)/2);
}

</script>

<body>
    <a href="javascript:f_OpenWin()">Click Me!</a>
</body>

</html>


The new window is width 200, and height 200,
Hence the top and left position both need -200 and /2 to make it center.

You can try to modify above code to reach your goal!


Hero
0
 
heronganCommented:
If the new window cann't open on the top level,
You can try following code.


<html>

<script language="JavaScript">

function f_OpenWin()
{
   var newWin = window.open ("http://yahoo.com","","width=200, height=200, top=" + (screen.height-200)/2 + ", left=" + (screen.width-200)/2);
   newWin.focus();
}

</script>

<body>
    <a href="javascript:f_OpenWin()">Click Me!</a>
</body>

</html>

Use a variable point to the newWin object.
Then using newWin.focus can make the new window on the top level. But i no need to add that code, the new window already open on the top level.


Hero
0
 
aksfluentAuthor Commented:
Thanks It works for me.can you please combine code with the code which checks for the browser for flash plugin and if the plugin founf it popups the new window otherewise it shows the page with animated .gif file.

Thanks
-Arun
0
 
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: herongan {http:#8126209}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now