473,394 Members | 1,658 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,394 software developers and data experts.

Capturing the onkeydown event i an IFRAME.

I have a mainpage where i display my menu and an iframe for the
content to load in. I want to trace keydown events i the Iframe. This
works well the first time I load the site. But when I load new content
in the iframe it seems like the eventlistner is destroyed. I can´t
really understand why. Because the onkeydown listner in the mainpage
is untouched.

Here is the code. Is there a solution to my problem?

<body>
<div id="appCont" style="position:absolute;top:5px;left:5px">
<iframe
scrolling="no"
name="appFrame"
src="splash.jsp"
frameborder="0"
width="990"
height="740">
</iframe>
</div>
<script type="text/javascript">
frames[0].document.onkeydown = function (evt) {
whichASC=(bw.ie)?frames[0].event.keyCode:evt.which;
alert(whichASC)
if(whichASC==81) {
ctrlPressed = true;
return false;
}
if(whichASC==9 && ctrlPressed) {
//do something
}
return true;
};
</script>
</body>
Jul 20 '05 #1
1 20066
On 15 Sep 2003 08:00:17 -0700, to************@zait.se (Tobias Åkeblom)
wrote:
But when I load new content
in the iframe it seems like the eventlistner is destroyed. I can´t
really understand why. Because the onkeydown listner in the mainpage
is untouched. frames[0].document.onkeydown = function (evt) {


Just a wild guess, but you are attaching the function to the
frames[0].document NODE and when you change locations the document is
destroyed and a new one re-created.

Try re-attaching the function to the new frames[0].document every time
you change locations. I suspect that might fix it.

Dale Hurtt
Jul 20 '05 #2

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

Similar topics

3
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
3
by: coolsti | last post by:
Can someone help me enhance this code snippet which works only for IE so that it will also work for Firefox? I have been trying all sorts of things and have gotten to where I can capture the...
3
by: euler | last post by:
why did the keydown event not fire in this simple example? <HTML> <HEAD><title>keydown_div</title> <script type="text/javascript"> function keydown() { alert("keydown"); } </script>
4
by: Jay Xx | last post by:
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...
10
by: b.dam | last post by:
I'm trying the following: function grid() { this._el = document.createElement("TABLE"); var self = this; document.addEventListener("onkeydown", function(event) {self.gridKeyDown(event);},...
2
by: George Durzi | last post by:
I have a text box and a button, and I want the enter key to run the click event of the button. The textbox and button are inside a user control. I tried all sorts of stuff with the __EVENTTARGET...
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...
9
RBPierce
by: RBPierce | last post by:
Hey all, hoping someone can help me with a workaround. I've got an event set to fire when a textbox changes or loses focus- no problems. However, when the user clicks into the box and Right Click-->...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.