Solved

New File  (Ctrl+N) Problem  in IE

Posted on 2004-04-30
12
448 Views
Last Modified: 2012-08-13
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!
0
Comment
Question by:dfiala13
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10961849
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
 
LVL 12

Author Comment

by:dfiala13
ID: 10962124
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10963738
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 12

Author Comment

by:dfiala13
ID: 10963976
I am aware of that.  Is there a client side way of catching it? Is there a way of preventing it?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10963987
Are you saying is there a way to catch the crtl + N key combination?

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10964001
Even if you did, that wouldn't stop someone from opeing a new window from the file menu.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10964059
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
 
LVL 12

Author Comment

by:dfiala13
ID: 10964103
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
 
LVL 46

Assisted Solution

by:fritz_the_blank
fritz_the_blank earned 200 total points
ID: 10964135
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
 
LVL 21

Accepted Solution

by:
ap_sajith earned 300 total points
ID: 10964156
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
 
LVL 12

Author Comment

by:dfiala13
ID: 10978201
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
 

Expert Comment

by:Evolutionmarketplace
ID: 11946479
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

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question