Opening and Closing Windows : Window « Window Browser « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » Window Browser » Window 
Opening and Closing Windows



/*
JavaScript Unleashed, Third Edition
by Richard Wagner and R. Allen Wyke 

ISBN: 067231763X
Publisher Sams CopyRight 2000

*/

<html>
<head>
<title>Window Open</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
     var newWindow
   
     // Open Window based on user defined attributes     function openWindow() {
   
          // Build the windowFeatures parameter list
          var winAtts = ""
          if (document.winOptions.toolbarOption.checked) {
               winAtts += "toolbar=1," }
          if (document.winOptions.menubarOption.checked) {
               winAtts += "menubar=1," }
          if (document.winOptions.scrollbarsOption.checked) {
               winAtts += "scrollbars=1," }
          if (document.winOptions.resizableOption.checked) {
               winAtts += "resizable=1," }
          if (document.winOptions.statusOption.checked) {
               winAtts += "status=1," }
          if (document.winOptions.locationOption. checked) {
               winAtts += "location=1," }
          if (document.winOptions.directoriesOption.checked) {
               winAtts += "directories=1," }
          if (document.winOptions.copyHistoryOption.checked) {
               winAtts += "copyhistory=1," }
          if (document.winOptions.customSizeOption.checked) {
               winAtts += "height=" + document.winOptions.heightBox.value + ","
               winAtts += "width=" + document.winOptions.widthBox.value + ","
          }
          winAtts = winAtts.substring(0, winAtts.length-2)
   
          // Determine URL and show window
          if (document.winOptions.pageType[1].checked) {
               var urlVar = ""
               urlVar = document.winOptions.urlBox.value
               newWindow = window.open(urlVar,"newWindow",winAtts) }
          else {
               newWindow = window.open("","newWindow",winAtts)
               newWindow.document.write("<H1>Window Open Test</H1><p>")
          }
     }
   
     // Close Window
     function closeWindow() {
          newWindow.close()
     }
// --></SCRIPT>
</head>
   
<body >
<h1><font color="#008040">Window Open Example</font></h1>
<p><i><b>Please select the following display options and then click
the Open Window button. </i></B></p>
<form name="winOptions" method="POST">
<p>Would you like an existing page or one created on the fly?</p>
<input
     type=radio
     checked
     name="pageType"
     value="existing">Existing Page
     <input
          type=text
          size=30
          maxlength=256
          name="urlBox"></p>
     <input
          type=radio
          name="pageType"
          value="dynamic">Dynamic Page</p>
<hr>
<p>Window Attributes:</p>
<pre><input
     type=checkbox
     name="toolbarOption"
     value="ON"
     >Toolbar    <input
     type=checkbox
     name="menubarOption"
     value="ON">Menubar    <input
     type=checkbox
     name="scrollbarsOption"     value="ON">Scrollbars   <input
     type=checkbox
     name="resizableOption"
     value="ON">Resizable</pre>
<pre><input
     type=checkbox
     name="statusOption"
     value="ON">Status     <input
     type=checkbox
     name="locationOption"
     value="ON">Location   <input
     type=checkbox name="directoriesOption"
     value="ON">Directories  <input
     type=checkbox name="copyHistoryOption"
     value="ON">Copy History</pre>
<pre><input
     type=checkbox
     name="customSizeOption"
     value="ON">Custom Size</pre>
<pre>Width: <input
     type=text
     size=5
     maxlength=5
     name="widthBox">  Height: <input
     type=text
     size=5
     maxlength=5
     name="heightBox">               <input
     type="button"
     name="OpenButton"
     value="Open Window"
     onClick="openWindow()">  <input
     type="button"
     name="CloseButton"
     value="Close Window"
     onClick="closeWindow()"></pre>
</form>
<p>&nbsp;</p>
</body>
</html>

           
       
Related examples in the same category
1. Make a new window
2. Communicating with a New Window
3. Using the window.close() Method to Close a Browser Window
4. Popup window animation (fly across screen)
5. Hyper link to close window
6. Close window and open document in new window
7. Open a new link from a button
8. Open a new window and control its appearance
9. Open multiple windows at one click
10. Resize a window
11. Resize a window to a specified size
12. Scroll the window
13. New Window Laboratory
14. Creating an always Raised Window
15. Window Property Picker
16. Window Resize, motion, maximize
17. Creating a New Window
18. Window Resize Methods
19. Window focus and blur()
20. Opening a New Window
21.  A Main Window Document
22. References to Window Objects
23. Simple Notification: Display Window Info
24. Properties and Methods of the Window Object
25. Capturing Click Events in the Window
26. Contents of a Main Window Document That Generates a Second Window
27. Setting Window Height and Width(Firefox)
28.  Checking Before Closing a Window
29. Open a window and center it
30. Maximize Window for different browser
31. Scroll Window
32. Open a new window setting height, width and position
33. Move a window
w___w_w___.__j___a___v___a2__s_.___co___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.