Click here!
 

Upload    Contact    Home
 


R E S O U R C E S

HTMLStuff:

 
 
Home
Artist
Designer
Webmaster
Programmer
What's New
* Resources
 

 

 

Pop-up Windows

     We know you can't stand pop-up windows. Many people and services use them the wrong way, but when used effectively they can be really helpful tools. For example, if you need to displayed some information and the user has a choice to open the pop-up window, then it's okay. Below is a short JavaScript that will fulfill our information pop-up needs.


<script language="JavaScript">

<!--
var popWin  // because of the closepopWin()
            //function it has to be declare global

function Popup(URL, NAME)
   { 
   //This opens the window
   popWin = window.open("URL","NAME",
   "toolbar=0,location=0,menubar=0,scrollbars=0," +
   "resizable=0,width=250,height=80");
   popWin.focus();
   }

function closepopWin()  
   { 
   //This function will close the popup window
   popWin.close()
   }


// If you want this to be automatic you'd
// add Popup(URL,NAME) and place it in the head 
// of the document 
// -->
</script>


Pop-up links would look like this <a href="javascript:Popup(URL,NAME);">text</a>

      I know it seems like a lot, but most of it is window tweaking. Here's an example of when it's a good time to use a pop up window. "I don't want you to leave this page but I need to show you a little info so I'll use a pop-up window." Click here to see your script in action. Click here to close Popup Window.

NOTE: The script is very fast, so make sure you look to see how many windows are open. When a Window is closed, it closes all the windows it launched.

If you would like to make a popup window to come up when a page loads, you can use the same code, but instead of creating a link you place the tag in the body tag. Like this;

<body background="blue" onload="Popup();">

You can still close this window with a link on the page with the popup Script. Everything on the link is the same, <a href="javascript:popWin.close()"> It's always good to include closing tools on one page if you're using popup windows the right way, so people won't have to go and close things one by one. Use popup responsibly and the web be a better place to be.  


Back to Tips & Tricks Menu
Back to Programmer Main Page
Back To HTML Stuff Main Page

 

  News   Contact   Advertise   CD ROM   Search   Upload   Help   Home

Copyright © 2000 Tucows.Com Inc.
TUCOWS.Com Inc. has no liability for any content or goods on the TUCOWS site or the Internet, except as set forth in the terms and conditions and privacy statement.