jump to contentsacramento state - leadership begins here  
sac state homeadmissionsabout sac stategiving a giftsite indexcontact us

Tutorials - JavaScript Close Button

When you are utilizing popup windows it is often nice to include a close button for these windows.  The visitor could easily click on the window's close button in the upper right-hand corner (or left-hand corner on a Macintosh). However, including this feature in your page will add a touch of personalization to your Web pages.

Step 1

Copy the following JavaScript and paste it into the <body> section of your document where you want the close button to appear.

<input type="button" value="Close Window" onClick="self.close()" />

Example

This sample popup window uses the JavaScript button from above.

CSC 258

last reviewed: January 25, 2008