Solved

New File  (Ctrl+N) Problem  in IE

Posted on 2004-04-30
12
441 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now