Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-02-2009, 06:30 PM   #1
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,239
Send a message via ICQ to wvxvw
Default MSIE6: prevent default for Ctrl+O|P|F

Hi, somehow I cannot find how to prevent these specific keysequences from their default behavior (Ctrl+O, Ctrl+P, Ctrl+F).
It seems like any other button can be prevented, but not these...
My first guess was that those are hardcoded, but it's not so, somehow Google Documents can open a pop-up when user hits Ctrl+O.
So, maybe there is some workaround, maybe in VBScript?..
My code so far:
HTML Code:
<script type="text/javascript">
	<!--// 
	function f()
	{
		document.kp = function(e)
		{
			var fl = document.getElementById("out");
			fl.keyevt({t:e.type, k:e.keyCode});
			e.preventDefault();
			e.stopPropagation();
			return false;
		}
		document.ku = function()
		{
			var e = window.event;
			e.cancelBubble = true;
			e.returnValue = false;
			if (e.stop !== undefined) e.stop();
			var fl = document.getElementById("out");
			fl.innerHTML = e.type;
			return false;
		}
		if (document.addEventListener !== undefined)
		{
			document.addEventListener("keydown", document.kp, true);
			document.addEventListener("keyup", document.kp, true);
		}
		else
		{
			document.onkeyup = document.ku;
			window.onkeyup = document.ku;
			document.onkeydown = document.ku;
			window.onkeydown = document.ku;
			document.onkeypress = document.ku;
			window.onkeypress = document.ku;
		}
	}
	f();
	//-->
	</script>
Any ideas?
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 11-02-2009, 09:02 PM   #2
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
Default

Not sure it's going to happen. All you really need to do is return false (e.preventDefault(), etc aren't needed). However, I think IE sees those key presses and passes them through to the OS. Not sure there's much you can do to supress that.
__________________

bad developer

Jordan Rift
yell0wdart is offline   Reply With Quote
Old 11-02-2009, 09:30 PM   #3
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,239
Send a message via ICQ to wvxvw
Default

Well, how then Google Documents do it? They definitely do it using JavaScript...
You can prevent Explorer .NET control from that behavior without recompiling it, that I know for certain... but, no idea how to do that / how Google are doing it using JS...

preventDefault is for DOM2 browsers, it's not called when in IE...
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it

Last edited by wvxvw; 11-02-2009 at 09:34 PM..
wvxvw is offline   Reply With Quote
Old 11-02-2009, 10:57 PM   #4
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
Default

Quote:
Originally Posted by wvxvw View Post
Well, how then Google Documents do it? They definitely do it using JavaScript...
You can prevent Explorer .NET control from that behavior without recompiling it, that I know for certain... but, no idea how to do that / how Google are doing it using JS...
Not quite sure, to be honest. I know they've done some pretty impressive stuff with DOM events, but I don't know how they accomplish it.


Quote:
Originally Posted by wvxvw View Post
preventDefault is for DOM2 browsers, it's not called when in IE...
I've had IE7 choke on e.preventDefault() before, so I don't think it gets ignored completely, though that might have been an IE problem with jQuery. Just brought it up as a caution. In my experience, it hasn't given me any benefit over just returning false.
__________________

bad developer

Jordan Rift
yell0wdart is offline   Reply With Quote
Old 11-02-2009, 11:45 PM   #5
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
Default

I'm stumped, honestly. I've tried every way I know how, but I can't seem to suppress those commands (Ctrl + C, V, F, O, or P) in IE. I can in Firefox or webkit browsers, but not IE. Seems to be one of Google's best kept secrets...
__________________

bad developer

Jordan Rift
yell0wdart is offline   Reply With Quote
Old 11-03-2009, 06:36 AM   #6
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,239
Send a message via ICQ to wvxvw
Default

Actually, I have an idea... need to check it though... what if on Ctrl you move focus to some, say, <inpupt> or <textarea> and then in that component wait for the next key?.. Or just dispatch fake key event in between? maybe it will trick it out of opening that window... I'll check in the evening and we'll see... Debugging Google code is really impossible.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 11-03-2009, 09:30 PM   #7
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
Default

That's an interesting approach. Let me know how that turns out. If that works, I could see engineering that into a fairly portable shortcut framework.


Quote:
Originally Posted by wvxvw View Post
Debugging Google code is really impossible.
Agreed. They do a fantastic job at obfuscating their JS.
__________________

bad developer

Jordan Rift
yell0wdart is offline   Reply With Quote
Old 11-04-2009, 02:05 AM   #8
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 3,239
Send a message via ICQ to wvxvw
Default

Nope, neither of them two worked
The closest I can get is to cause some error in between capturing Ctrl and O... but this doesn't sound like a way to go...
Even if for example you hit Ctrl+Shift+O the dialog won't open, but if you fake the Shift button, then the dialog opens anyway, even though the Shift is displayed as pressed.
Moving focus anywhere doesn't work either...
Besides, I don't think I have managed to crash IE so many times in a row, as I did that today
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:19 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.