473,287 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Is Capturing keypress in a designMode IFrame possible?

I have an IFrame in design mode. I've tried a bunch of things to
capture key presses in that IFrame, but I can't seem to get it. I can
capture key presses outside the IFrame fine. I have this problem in
Firefox, not IE.
I do know it's possible because Blogger.com's rich text editor does it,
but their code is cryptic and separated into like 20 files, so I'm
going through hell trying to decipher it.
(I need to capture the keypress in order to cancel Ctrl-B from opening
the bookmarks sidebar)

Jul 23 '05 #1
4 11939


Jay Xx wrote:
I have an IFrame in design mode. I've tried a bunch of things to
capture key presses in that IFrame, but I can't seem to get it. I can
capture key presses outside the IFrame fine. I have this problem in
Firefox, not IE.


It shouldn't be any different to capturing key events in a normal
iframe. Do you really have code capturing key events in a normal iframe
with Mozilla that stops working if you switch designMode on for that iframe?
Could you post a URL where that happens? Do you get script errors? What
exactly goes wrong, capturing the key event with a handler, or perhaps
only cancellation of a key?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Yes, here is a simple example of it not working:
http://www.jayssite.com/misc/iframesample.html
I don't get any errors. The event simply isn't captured.

I've also uploaded
http://www.jayssite.com/misc/iframesample2.html
In this example I've commented out the designMode setting, and instead
I've put a textarea in the IFrame. Capturing keypresses works fine in
that example. (Each keypress brings up an alert box)

Jul 23 '05 #3
After extensively searching Blogger.com's code, I've found the rather
simple solution:

document.getElementById('edit').contentWindow.addE ventListener('keypress',
cK, true);

Thanks anyway!

Jul 23 '05 #4


Jay Xx wrote:
Yes, here is a simple example of it not working:
http://www.jayssite.com/misc/iframesample.html
I don't get any errors. The event simply isn't captured.


I am not sure what is different but here is an example working for me
with Mozilla 1.7
<http://home.arcor.de/martin.honnen/javascript/200503/test2005031201.html>
Onload the keypress handling is enabled and when the user types in the
iframe the key/char code is reported.
There are buttons then to disable the keypress handler and enable it
again which work too.

Although I also put in some code in that example geared towards IE I
haven't tested with IE as your original post says you are not looking
for an IE solution.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas | last post by:
Hy dudes, I have a strange problem. I dynamically create an IFrame with JavaScript and then fill in some content. Afterwards I want to switch to designMode. There the trouble starts. In Mozilla...
3
by: Bob Rivers | last post by:
Hi, I'm trying to build a web page where the user can insert text dinamically. When the user hits a button, a new text box is created and the user can insert text into it. It's working nice...
1
by: Marcel Balcarek | last post by:
I have an IFrame control defined. Is there a way to turn designMode on for it, so that I can edit text in it using richtext capabilities? These IFrame controls awill be defined dynamically in...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
2
by: Simon Rigby | last post by:
Hi folks, I'm trying to switch an iFrame in and out of design mode by way of a script. As you can see from the method it is intended to be cross browser compatible (or FF and IE at least). The...
9
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the...
2
Patropia
by: Patropia | last post by:
Hi, I have an iframe that's using designMode in which I'm loading some code. When including an iframe in that code (putting an iframe in the iframe) the entire frame goes blank. This only happens...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.