/** * landgate_popup.js * * JavaScript functions to handle browser window management. */ /** * Open the specified URL in a new popup window, which is resizable and scrollable but * does not have a location bar, status bar or menu bar. * * NOTE: To use this function, you must not break accessibility for users that do not * have JavaScript enabled. The HTML code to open a page at the address "/page.html" * is as follows (note the "return false" part, it is important): * * ... * * @param url The URL to open. * @param popupWidth (OPTIONAL) Width of the window to open; defaults to 800. * @param popupHeight (OPTIONAL) Height of the window to open; defaults to 600. */ function popupURL(url, popupWidth, popupHeight) { // Assign default values to arguments. popupWidth = popupWidth ? popupWidth : 900; popupHeight = popupHeight ? popupHeight : 700; // Get the size of the screen. var screenWidth = window.screen.width; var screenHeight = window.screen.height; // Determine the on-screen position (x, y). var x = (screenWidth - popupWidth) / 2; var y = (screenHeight - popupHeight) /2; // Open the window for the specified URL. var options = 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+popupWidth+',height='+popupHeight+',left='+x+',top='+y+',screenX='+x+',screenY='+y; window.open(url, "_blank", options); } /** * Centre the current window on the screen, after setting it to the specified size. * * @param width Width for the window, defaults to 800. * @param height Height for the window, defaults to 600. */ function centreWindow(width, height) { // Assign default values to arguments. width = width ? width : 800; height = height ? height : 600; // Get the size of the screen. var screenWidth = window.screen.width; var screenHeight = window.screen.height; // Determine the on-screen position (x, y). var x = (screenWidth - width) / 2; var y = (screenHeight - height) /2; // Set the size and position. window.resizeTo(width, height); window.moveTo(x, y); }