Open centre screen

  • lomilmand
  • Student
  • Student
  • lomilmand
  • Posts: 91
  • Loc: Bournemouth, UK

Post 3+ Months Ago

Anyone know how to adapt this code so that the new window open in the centre of the screen? Thanks for any help or advice :wink:

Code: [ Select ]
<script type="text/javascript">
<!--

var newwindow;
function musicopen(url)
{
newwindow=window.open(url,'name','height=50,width=320');
if (window.focus) {newwindow.focus()}
}
// -->
</script>
  1. <script type="text/javascript">
  2. <!--
  3. var newwindow;
  4. function musicopen(url)
  5. {
  6. newwindow=window.open(url,'name','height=50,width=320');
  7. if (window.focus) {newwindow.focus()}
  8. }
  9. // -->
  10. </script>
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

the new window has a top and left properties
you can set them to center your image...but it will only be exactly centered on whatever resolution u choose to set the top & left values for
  • Vladdrac
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2136
  • Loc: Louisville, Ky

Post 3+ Months Ago

you couldn't set a percentage value for the top and left values i wonder?
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

<<<<<<wasn't thinking...percentages...yea...duh...that'd work
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

well, it wouldn't cos 50% (for eg) would put the top left corner in the middle. You can't use percentages to get the center of a pop-up into the center of the screen for <b>every</b> res.....

Try
Code: [ Select ]
var popWidth  = 320;
var popHeight = 50;
var popLeft  = (screen.width - popWidth) /2;
var popTop   = (screen.height - popHeight) /2;
  1. var popWidth  = 320;
  2. var popHeight = 50;
  3. var popLeft  = (screen.width - popWidth) /2;
  4. var popTop   = (screen.height - popHeight) /2;

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 21 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.