(Source Code) JavaScript - Auto Popup Window

Java Script Source Codes 

JavaScript - Auto Popup Window

Automatically opens a small popup window and closes it after a specified time. Great for displaying important messages without forcing users to close multiple windows!

This demo will open a small popup window 3 seconds after the page is loaded and close the window after it has been open for 5 seconds


<!-- THREE STEPS TO INSTALL AUTO POPUP WINDOW:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the onLoad event handler into the BODY tag
  3.  Put the last coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popupWin() {
text =  "<html>\n<head>\n<title>This is a Pop Window</title>\n<body>\n";
text += "<center>\n<br>";
text += "<a href='http://allfree-stuff.com' target='_blank'><h2>ALL FREE STUFF for you </h2></a>";
text += "</center>\n</body>\n</html>\n";
setTimeout('windowProp(text)', 3000);   // delay 3 seconds before opening
}
function windowProp(text) {
newWindow = window.open('','newWin','width=300,height=100');
newWindow.document.write(text);
setTimeout('closeWin(newWindow)', 5000); // delay 5 seconds before closing
}
function closeWin(newWindow) {
newWindow.close();    // close small window and depart
}
//  End -->
</script>

</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->

<BODY onLoad="popupWin()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document  -->

<center>
This demo will open a small popup window 3 seconds after the page is loaded and close the window after it has been open for 5 seconds.
</center>