How to Redirect With a Window Modal

A modal window lets you create a popup for your Web page and return a value to the parent page. The modal window is the child and the original window that displays your website is the parent. You can detect if a user supplies feedback in the modal window, then redirect the parent window to another Web page. This process lets you redirect a user based on user input.

Instructions

    • 1

      Right-click the HTML file you want to edit, and select "Open With." Click the HTML editor in the submenu.

    • 2

      Locate the JavaScript opening and closing script tags. If you don't already have the tags defined, add the following code to your HTML code:

      <script type="text/javascript">

      </script>

    • 3

      Create the function for the modal window. The following code opens a modal window and redirects users based on input returned from the user:

      function viewOptions() {

      input = window.showModalDialog("modal.html");

      if(input!= null) {

      window.location = "newpage.html";

      }

      }

      The code above detects if user input was sent from the modal dialog window. If the user applied some input, the browser redirects to the "newpage.html" Web page.

    • 4

      Link the function to a button on your Web page. The following code is an example of a button that calls the JavaScript function and opens the modal dialog window:

      <input type="button" value="Open Modal Window" onclick="viewOptions()">

Related Searches:

References

Comments

Related Ads

Featured