Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript to reload page on unLoad

    Hello all!

    I want to use a JavaScript that allows me to make the user fill out a form. The form is loaded in a 3-frame frameset in the main window, and there are navigational links in the left frame that change what is displayed in the main frame.

    I want to set up the form so that it will be reloaded if the user tries to escape by clicking on any of the nav links in the left frame.

    I understand that it requires an onunLoad event handler in the <body> tag, but I cant get my head around the function that needs to be set up in order to execute this event.

    Help!

    mmasci

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    you must set up your navigation page like this:

    function openPage(url){
    fillUpPage = "YourFillUpPageHere.htm";//this is the page where the user must fill-up the form
    if (top.frames["YourMainFrameNameHere"].location.href.indexOf(fillUpPage)!=-1){
    top.frames["YourMainFrameNameHere"].location.href=fillUpPage;
    }
    else{
    top.frames["YourMainFrameNameHere"].location.href=url;
    }
    }


    then in your links:

    <a href="javascript:openPage('link1.htm')">Link1</a>
    <a href="javascript:openPage('link2.htm')">Link1</a>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •