New File (Ctrl+N) Problem in IE

Here's the situation, it's a bit a tricky...

A classic ASP application

User opens the IE browser to run the web app and then creates an instance of the web app in another IE window, sharing the same session and cookies.  This causes some problems.

This there any way to do any of the following...
1) prevent user from selecting New File command in IE
2) trap the fact that this has occurred and start a new session or redirect the user to a login page

Note: this is an Internet app, so opening the app in a menuless window is not an option.  Would prefer an ASP only or javascript solution.

Thanks!
LVL 12
dfiala13Asked:
Who is Participating?
 
ap_sajithConnect With a Mentor Commented:
I dont see any means..

Unless you store some value in a cookie or database which says that the current page opened at (time).

For example, when i execute the current page, i add a cookie value called page with the page name as the key and the current time as the value.

When i open the page, i would be checking if the cookie value exists, if it exists, i have opened a new window. If it doesnt, i am opening the page for the first time.

The cookie value should be cleared when the user logs out and preferably when the user moves on to a different page. This can be easily achieved by iterating through the cookies collection.

Just an idea.. you'll have to work on it.

Hope this helps..

Cheers!!
0
 
ap_sajithCommented:
Dont think its quite possible...

Also, Open in a new window does not create a new session. and there is no way to trap it.

Why are are even contemplating doing this?

Cheers!!
0
 
dfiala13Author Commented:
I would like to see if someone knows of a way to figure out when this action has happened.  It is not something I want to do, but need to deal with because of the behavior of IE.  
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
fritz_the_blankCommented:
Think of this way--the new open window is a client side event, so there is no real way of server-side code catching that.

Fritz the Blank
0
 
dfiala13Author Commented:
I am aware of that.  Is there a client side way of catching it? Is there a way of preventing it?
0
 
fritz_the_blankCommented:
Are you saying is there a way to catch the crtl + N key combination?

FtB
0
 
fritz_the_blankCommented:
Even if you did, that wouldn't stop someone from opeing a new window from the file menu.

FtB
0
 
fritz_the_blankCommented:
But here is some code for you to look at (not mine):

<html>
<head>
<script type="text/javascript">
<!--
window.onload = function() { document.onkeydown = register;      document.onkeyup = register; var x = document.forms[0].elements[0];      x.onkeydown = register;      x.onkeyup = register;}
function register(e)
{
      if (!e) e = window.event;
      var keyInfo = String.fromCharCode(e.keyCode) + '\n';
      keyInfo += 'Event: ' + e.type + '\n\n';
      keyInfo += 'You pressed: ' + String.fromCharCode(e['keyCode']) + ' [Decimal: ' + e['keyCode'] + ']\n';
      keyInfo += 'ALT: ' + e['altKey'] + '\n';
      keyInfo += 'CTRL: ' + e['ctrlKey'] + '\n';
      keyInfo += 'SHIFT: ' + e['shiftKey'] + '\n';
      keyInfo += 'REPEAT: ' + e['repeat'] + '\n';
      keyInfo += 'WHICH: ' + e['which'];
      document.forms[1].log.value = keyInfo;
}

// -->
</script>
</head>
<body>
    <form action="return false;" >
       <p> <b>Enter something here: </b><br />
        <br />
        <textarea cols="24" rows="6" style="width:220px;border: 1px #ccc
solid"></textarea>
      </p>
      </form>
    </div>

    <div style="margin-left: 24px; float:left; margin-top: 51px">
     <form action="return false;">
      <p>
      <b>And the key events will be displayed here: </b><br />
        <br />
        <textarea style="background: #eee; border: 1px #ccc solid; padding: 15px; overflow: hidden; width: 330px; font-family: Arial, sans-serif; font-size: 11px" name="log" rows="12" cols="42"></textarea>
        <br />
        <br />
        <input type="button" value="Clear key info"      onclick="document.forms[1].elements['log'].value = ''" />
       </p>
      </form>
     </div>

</body>
</html>


FtB
0
 
dfiala13Author Commented:
I will restate:

is there a way to detect the File New event in IE, no matter how it is generated?

Barring that , when the newly created is requested from the server, is there some clever way to detect that this page was created using File New?


0
 
fritz_the_blankConnect With a Mentor Commented:
To review:

>>Is there a way to detect the File New event in IE, no matter how it is generated? <<

No, since the web is essentially stateless, there is no way for server-side code to detect what happens client side. With the JavaScript that I gave you, it is possible to make a client-side detction of the ctrl-N keyboard event, but there is nothing that can be done to detect the File-->New-->Window


>>Barring that , when the newly created is requested from the server, is there some clever way to detect that this page was created using File New?<<

No.

Fritz the Blank
0
 
dfiala13Author Commented:
Thanks for all the responses. The cookie idea looks the only possibility.  Shame to have to include the code on every page, but doesn't offer any control higher up the pipeline as ASP.NET does.
0
 
EvolutionmarketplaceCommented:
Dear ap_sajith,

Your solution with the cookies is fantastic, and I am trying to apply it but with a session variable.

My question is, what happens when the user refreshes the screen (F5)?, is there any way to detect or prevent the user from using the F5 key?

Thanks,

Pablo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.