Solved

New File  (Ctrl+N) Problem  in IE

Posted on 2004-04-30
12
453 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
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.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API not working 33 67
SQL Filter Question 8 86
Query still returning duplicates 5 41
IIS 7 and executing pages using localhost 16 14
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 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