Click to See Complete Forum and Search --> : function for all pages


GingerNutter
03-24-2004, 08:23 AM
I have an include js file that i link to in all of my pages. What I want to do is create a onkeypress function for every one of my pages without having to go into each one and type onKeyPress=MyFunction() into the BODY tag.
Is there someway to put the onkeypress comman in the js include file?

requestcode
03-24-2004, 09:13 AM
Do you mean something like this?
<Script language="JavaScript">
IE = document.all? 1:0;
if (!IE) // must capture for Netscape
{document.captureEvents(Event.KEYPRESS)}
document.onkeypress = testKey;
function testKey(e)
{
whKey = IE? event.keyCode:e.which;
alert(whKey)
}
</Script>

GingerNutter
03-24-2004, 09:16 AM
Absolutely perfect.

Thanks very much.