matterdaddy
 
Home Portfolio Capabilities Scripts Contact 
Scripts


Photo Album
Matterdaddy Market
Web Sites
Centered Popups







Centered Pop-Up Window

If you use Dreamweaver to write some of the more mundane things such as image roll-overs and opening secondary windows, here is a modification to Macromedia's MM_openBrWindow() function that opens pop-up windows in the center of your screen.

If you are familiar with Fitt's Law, you know that the time to acquire a target is a function of the size of the target and distance to the target. This puts the target dead-center and consistently in the same location. If you have ever positioned windows in the upper left corner of the screen you know how obnoxious it is (especially in applications) as it not only far from the mouse but further from the eyeballs which makes reading difficult.

View Sample

Copy this code and replace your MM_openBrWindow() function with it.

function MM_openBrWindow(theURL,winName,features) { //v2.0
new_width = features.substring(features.indexOf("width=")+6, features.indexOf("width=")+9) * 1
new_height = features.substring(features.indexOf("height=")+7, features.indexOf("height=")+10) * 1
var left = Math.floor( (screen.width - new_width) / 2);
var top = Math.floor( (screen.height - new_height) / 2)
var winParms = "top=" + top + ",left=" + left
if (features) { winParms += "," + features; }
window.open(theURL, winName, winParms);
}

© 2008 Cary Evans