Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get window.event.keycode from an I-frame? 1

Status
Not open for further replies.

TroyMcClure

Technical User
Oct 13, 2003
137
0
0
US
I have javascript in the main page, which has an Iframe. Within the Iframe, there are textboxes. I want to trap keystroke keycodes from those textboxes inside the iframe. The source of the iframe is an asp page, and I have a function call for the onkeydown of the texboxes input tag.

The problem is that the function I'm calling within the iframes source code does not exist in that asp page--the function is part of the parent window's code. I can't have that function duplicated in the iframe--I need a way to call the parent window's function from the iframes textbox code--in addition I need the either pass the keycode from the iframe, or to reference the event.keycode of the Iframe from the parent windows javascript code.

Can this be done? Thanks,
T
 
<frame-name>.function-name(...) is the generic format for targetting a cross-frame call; in this case parent.function-name(...) ought to do it.
 
MOrac,
Thanks very much. I've got that part down--where I can call my keyboard handler in the parent window from the inner iframe. Now, in the parent window's code--it doesn't seem to recognize event.keycode.

How can I get the parent's javascript to know the event.keycode of the event--onkeydown--of the textbox which exists in the iframe? It seems that since the keydown event happened in the context of the textbox in the iframe--that by the time the funcion in the parent window get's it then the event is gone. The code is very basic, it's in the Input tag of for the textbox in the table in the Iframe:
Code:
<td><input type="text" onKeyDown=parent.keyhandler('txtCust') name="txtCust" id="txtCust" ></td>
Thanks for any more insight,
--T
 
TroyMcClure,

Just in case... it is event.key[red]C[/red]ode not event.keycode.

regards - tsuji
 
The code you've written doesn't pass the event object on to the keyhandler function. I would suggest that you try doing that (onKeyDown="parent.keyhandler('txtCust', event)").
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top