JavaScript Popup Windows

Popup windows are additional browser window opened from a web page. The popups are opened programmatically using JavaScript.

JavaScript Popup windows are used widely for displaying advertisements. It is a proven method of generating good income from a website.

Uses of Popup Windows

In general the following are the ways to utilize popup windows:

  • Pay per click advertisements
  • Banner exchanges
  • Request survey from the visitors
  • Request signup to a news letter
  • Display help (for a form, for example)

    Note:
    You can create full featured, great looking popups without any programming.
    Click here for more info

    Invocation methods

    The invocation of the Popup is dependant on the purpose of the Popup window. A help popup window could be opened when the user clicks on a 'help' link.
    Advertisements usually pop up when you visit a web page or when you exit a page.

    Based on the invocation method, Popups are of the following types:

  • Open on entering a page
  • Open on entering a page; but keep inactive ( also known as Pop Under)
  • Open on exiting a page
  • Open when the user clicks on a link or a button

    Creating a JavaScript Popup window

    In order to invoke the popup window at certain instances (like when the page is loading) you need to understand the event handling. For example, if you want to popup a window when the user visits a page, you need to handle the onLoad event of that page. The following section event handling.

    The code below handles the onLoad event and displays a message.

    <BODY onLoad="javascript: alert('On Load event fired!')">

    The event handler is added in the onLoad event of the <BODY> tag of the page.

    Similarly, the following code shows the handler for the unload event.

    <BODY onUnload="javascript: alert('Unload event fired!')">

    Suppose you want to handle the event when the user clicks on a link. The following code shows handling the click on an anchor

    <A href="javascript: alert('Clicked on link!')">Click here!</A>

    The next section shows in detail, the code for opening a window.

    Next: The window.Open method >>

    • Digg
    • del.icio.us
    • Netscape
    • Reddit
    • StumbleUpon
    • Technorati
    • YahooMyWeb

    How to make a form without coding? Click here for a demo.

    Follow me on twitter

    HTML Forms
    HTML Form Tutorial
    The Form Tag
    The Form Submit Button
    Form design software
    How to make a web form
    Make web forms quickly, without coding

    Javascript Form Handling
      Basics
    Using getElementById to get the elements in a form
    Set value of form element using JavaScript
    Get value of form element using JavaScript
    Handling multiple forms using JavaScript
    JavaScript reset/clear a form
      Advanced
    JavaScript Form Validation
    Submitting a form using JavaScript
    Can JavaScript Email a Form?
    Switching the form action field dynamically
    JavaScript Button

    JavaScript Popup Windows
    The window.open method
    The window.close method
    More ...

     
    .   Copyright © 2003-2009 JavaScript-coder.com. All rights reserved.