?
Solved

window.open new window on top and center of screen

Posted on 2003-03-13
6
Medium Priority
?
954 Views
Last Modified: 2008-02-26
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
Comment
Question by:aksfluent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 

Author Comment

by:aksfluent
ID: 8126158
Please help me out I tried with alwaysRaise=1 but it works in Netscape but not in IE and Modzilla.
0
 
LVL 1

Expert Comment

by:herongan
ID: 8126174
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
 
LVL 1

Accepted Solution

by:
herongan earned 75 total points
ID: 8126209
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
 

Author Comment

by:aksfluent
ID: 8128975
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10130580
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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question