views:

956

answers:

3

How do you disable the Ctrl+N/File->New options from browser windows, specifically for IE.

+2  A: 

How much control do you have over the clients?

If you're just serving a page publicly on the WWW, then there's no way.

If you're running a kiosk or a classroom of computers or something, then you could probably hack something together to watch for instances of IE, and disable the menus and trap the Ctrl+N key combination.

zildjohn01
I'm serving a page publicly on WWW
Mac
+2  A: 

Based on the comments, it sounds like you are trying to fix the symptom and not the problem itself. The approach you are hinting at is likely to be of limited use (only works in certain browsers) anyway.

I suggest you post the details of your duplicate session problem and let us take a crack at that.

JohnFx
I don't know that we have bad code that's causing the duplicate session problem. It's just that when you open a new window, the users are working with another instance of the same session from the first window and therefore data is overwritten if they save anything in the new window. Is there a way to prevent that?
Mac
I get that. My point is that you should fix your app to handle the situation gracefully instead of trying to stop the user from doing something that is useful to them. Without knowing the details it is hard to make suggestions, but let me take a shot anyway. Have you considered saving the state information for this page in the page itself instead of using session objects to do the dirty work? That could fix the underlying problem instead of the symptom.
JohnFx
A: 

Hi guys i am also looking for this, As per my knowledge we can disable only ctrl+N key for new window. Here is the code document.onkeydown = function() { alert(event.keyCode) if ((event.keyCode == 78) && (event.ctrlKey)) { alert ("No new window") event.cancelBubble = true; event.returnValue = false; event.keyCode = false; return false; } }

If any one have idea to diable new window option from browser menu bar through any code login, please provide me on urgent basis.

Abhay R.

Abhay
You might wanna post a new question if your question is different that the original. Also please be specific and clear in your question.
Mac
The above javascript code works in window without any frames. I have a similar problem but in my case there are 3 frames with one of them fixed (menu bar where I can put this code), but this event is not caught if the focus is in some other frame. How can I implement this restriction globally on a browser window?
Tushu