Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

FRAMESET onUnLoad and IE

I am developing an extranet where clients log in.  In order to figure out when they leave (and do some mop up work) I set the whole extranet (after the login screen) into a 1 frame frameset.  On that page I use the frameset's onUnLoad event to do the logout mop up work, and display a goodbye window for 5 secs.  Now this works good for the most part.  If someone types an address, it will try to unload the frameset and I'm in business.
     But here's the problem.  A user, if they choose, should be able to open up a new browser window and go elsewhere.  In NS theres no problem.  The new window opens up with their homepage, and they can go anywhere they want.  But in IE the new window opens up with the eact same page as what was in the first window.  If the user then goes elsewhere on the 2nd window it triggers the onunLoad event, and the user is logged out of both windows!

     How can I work this so it doesn't happen?  Thanks in advance.

:) dapperry
0
dapperry
Asked:
dapperry
  • 4
  • 4
  • 3
  • +1
1 Solution
 
dog42Commented:
Just an idea,
you could load your page into a new window when the user logs on, and then the 'mop up' function could check the window name before doing it's job.

Dog42
0
 
dog42Commented:
That is,
When a user logs on, load the page to a new window:
window.open('loggedOn.htm','winName')
and then, in the frameset write:
onUnLoad="if(window.name=='winName')doLogOutF()"

You could even write a piece of code to only do this check if the browser is IE.

Dog42
0
 
dog42Commented:
Sorry, ignore that.  I just realised that this would stop the cleaning function if someone typed in a url.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dapperryAuthor Commented:
Is there any way to tell if its the uppermost parent window?

:) dapperry
0
 
nettromCommented:
No, there's not, unfortunately (not as long as we're talking JavaScript).  JavaScript has no knowledge of other browser windows unless you've opened them (using window.open()) or you are an opened window (the 'opener' object points to your parent).
0
 
kollegovCommented:
Time to use use temporary cookie!
1. when load, check cookie not set yet
and assign handler, and set temporay cookie.
2. if cooike already set than do not assign onload handler...

Do you need cookie functions?
0
 
kollegovCommented:
Time to use use temporary cookie!
1. when load, check cookie not set yet
and assign handler,
2. if cooike already set than do not assign onload handler...

Do you need cookie functions?
0
 
dapperryAuthor Commented:
nettrom,
      If someone goes File|New|Window could the page check to see if opener is valid?  Say
 
if (self.opener) {
    //dont do anything
}
else {
    //Do the mop up stuff
}

kollegov,
    I think I get your idea.  But I think I need some example code (w/cookies) to fully get it.

:) dapperry
0
 
kollegovCommented:
Simplest way is few lines

<script>
function doclean(){
 //your clean stuff here
 //.......
 //change cookie to 'no'
 document.cookie='a=n';
}

if(document.cookie.indexOf('a=y')==-1){//assign handler and set cookie
 document.cookie='a=y';
 window.onunload=doclean;
}
</script>

You even do not need cookie functions to store single var named a with value
'y' or 'n',  you can just chech this substring exists in cookes string
0
 
dapperryAuthor Commented:
Kolegov,

This isn't quite working.  Heres my present code, maybe you could figure out whats going on.

<script language="javascript">
     function LogOut() {
          xpos=600;
          ypos=200;
          urlstring="logout.cfm";
winfeatures="scrollbars=yes,screenX="+xpos+",screenY="+ypos+",height=200,width=600";
            winlogout=window.open(urlstring,"winlogout",winfeatures);
          document.cookie='a=n';
      }
      if(document.cookie.indexOf('a=y')==-1){//assign handler and set cookie
          document.cookie='a=y';
        window.onunload=doclean;
    }
</script>       
<frameset rows="100%,0" border="0" onUnload="return LogOut()">
      <frame src="main.cfm">
</frameset>  


The onunLoad of the frameset is supposed to fire up a small window with a page that handles the cleanup.  I just don't want it to happen if the person wants to redirect a new browser window.

Many thanks,

:) dapperry
0
 
kollegovCommented:
This must work:

<script language="javascript">
                    function LogOut() {
                         xpos=600;
                         ypos=200;
                         urlstring="logout.cfm";
               winfeatures="scrollbars=yes,screenX="+xpos+",screenY="+ypos+",height=200,width=600";
               winlogout=window.open(urlstring,"winlogout",winfeatures);
                         document.cookie='a=n';
               }
               if(document.cookie.indexOf('a=y')==-1){//assign handler and set cookie
                    document.cookie='a=y';
                       window.onunload=LogOut;
                   }
               </script>
               <frameset rows="100%,0" border="0">
               <frame src="main.cfm">
               </frameset>  
0
 
dapperryAuthor Commented:
Thank you!!  That worked wonderfully.

:) dapperry
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now