JavaScript is disabled! Please enable JavaScript in your web browser!

Freestyle Academy of Communication Arts & Technology

1299 Bryant Ave, Mt. View, CA 94040 T 650-940-4650 x5090
2 Required Classes: English and Digital Media 3rd/Elective Class:  + Animation or Design or Film

Back to list of all examples

Useful Stuff About:

Auto Centering Pop Up Window

This example is a typical pop up window that displays itself at the top left of the user's browser screen.

Click me of the image below to see the typical pop up window:

 

You do have the option to CENTER the pop-up window horizontally and vertically.

Click me or the image below to reveal a pop-up window that CENTERS itself to the user's monitor screen

How do you do this? Paste the following JavaScript in the <head>


<script type="text/javascript">
function openPopUp(newPage,w,h) {
      var windowName='newWindow';
      var popUpX=(screen.width-w)/2;
      var popUpY=(screen.height-h)/2;
      var features='width='+w;
      features=features+', height='+h;
      features=features+', top='+popUpY+', left='+popUpX;

      //You can change the the following if you wish
      features=features+', scrollbar=yes'; 
      features=features+', resizeable=no';
      features=features+', toolbar=no';
      features=features+', location=no';
      features=features+', menubar=no'; 
      features=features+', status=no';

      window.open(newPage,windowName,features);
}
</script>

The text or image link needs to be as such below:


<a href="#"
onclick="openPopUp('pathToPage','pageWidth','pageHeight')"

      Text or <img> tag in here
</a>