home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 88 / PIWD88.iso / pc / CONTENTS / DREAMWEAVER / TUTORIAL_FILES / Pages58-60 / ASSETS / JSCRIPT / JS_POPUP.TXT
Text File  |  2003-11-05  |  2KB  |  63 lines

  1. <!-- 
  2.  
  3. // popup window variables
  4. var windowWidth=400;
  5. var windowHeight=270;
  6. var windowPositionFromLeft = 250;
  7. var windowPositionFromTop = 100;
  8. var windowTitle = "CD Preview Window";
  9. var windowCode = "width="+windowWidth+",height="+windowHeight;
  10.  
  11. // set autoClose to true to close pop-up window automatically if user leaves the launching page; else, false 
  12. var autoClose = true;
  13.  
  14. // test to check user's browser type (value will return true for Internet Explorer)
  15. var checkBrowser = document.all?true:false
  16.  
  17. function openFramelessPopUpWindow(pageName) {
  18.  
  19.     if (checkBrowser) {
  20.     
  21.         // script for Internet Explorer - creates a frameless pop-up window
  22.         newPopUpWindow = window.open("","cdPopUpWindow","fullscreen,"+windowCode);
  23.         newPopUpWindow.blur();
  24.         window.focus();
  25.         newPopUpWindow.resizeTo(windowWidth,windowHeight);
  26.         newPopUpWindow.moveTo(windowPositionFromLeft,windowPositionFromTop);
  27.         
  28.         //  frameset code to generate scroll bars for pages larger than the frameless pop-up window page area
  29.         var framesetHTMLCode=""+
  30.         "<html>"+
  31.         "<head>"+
  32.         "<title>"+windowTitle+"</title>"+
  33.         "</head>"+
  34.         "<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
  35.         "<frame name='top' src='"+pageName+"' scrolling=auto>"+
  36.         "<frame name='bottom' src='about:blank' scrolling='no'>"+
  37.         "</frameset>"+
  38.         "</html>";
  39.  
  40.         // write frameset code dynamically to the frameless pop-up window
  41.         newPopUpWindow.document.open();
  42.         newPopUpWindow.document.write(framesetHTMLCode);
  43.         newPopUpWindow.document.close();
  44.         
  45.     } else {
  46.     
  47.         // Script for all other browsers - creates a standard pop-up window with title and auto scroll bars
  48.         newPopUpWindow = window.open(pageName,"cdPopUpWindow","scrollbars,"+windowCode);
  49.         newPopUpWindow.blur();
  50.         window.focus();
  51.         newPopUpWindow.resizeTo(windowWidth,windowHeight);
  52.         newPopUpWindow.moveTo(windowPositionFromLeft,windowPositionFromTop);
  53.         
  54.     }
  55.  
  56.     //  if autoClose set to true the following code closes the pop-up window when the launching page is left
  57.     newPopUpWindow.focus();
  58.     if (autoClose) {
  59.         window.onunload = function() { newPopUpWindow.close();
  60.     }}
  61.     
  62. }
  63. // -->