FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

JavaScript Tutorial: Opening a New window Centered on the Screen using Javascript

jawahar
8/28/2005 11:38:58 PM, Views: 2288
Have the following code to load the filename.html open centered in
the screen.

Remember : please have any .html file named as filename.html where
the following file is,

<html><head>
<script language=javascript>
function openWinCenter()
{
leftPos = 0
topPos = 0
if (screen)
{
   leftPos = (screen.width / 2) - 251
   topPos = (screen.height / 2) - 162
}
ElementWindow = window.open
('filename.html','WinTitle','width=502,height=325,left='+leftPos+',to
p='+topPos)
}
</script>
</head><body>

The function call within the anchor is simple on this one:
<a href="javascript:openWinCenter()">Click to View a Window aligned
Centered!</a>
</body>
</html>
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Avg Visitor Rating: Average Visitor Rating is 4.5 out of 5
Number of Ratings : 3 Votes
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
JavaScript RSS Feed
Most Popular Tutorial
Most Popular Solution
Top Rated
Top Rankers
Overall
1. jawahar (1400)
Yearly -2008
1. jawahar (200)
Expertsforge Sponsors
bnrtop