Results 1 to 4 of 4

Thread: JS - Enabling Function Keys

  1. #1
    Join Date
    Jan 2010
    Location
    UK
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default JS - Enabling Function Keys

    1) CODE TITLE:
    Javascript - enabling function keys

    2) AUTHOR NAME/NOTES:
    Rob Dixon - AS/400 (iSeries, i5) developer

    3) DESCRIPTION:

    I am trying to create a new browser based interface for my AS/400 database product. The HTML and JS code is all generated by my product - there is no static code. I want to be able to provide short cut keys for all buttons. I have got some working - e.g. F11, F12, F15 (F3 +shift), F16 but cannot get F3, F5 or PgUp or PgDn to work. I had F3 and F5 working in an earlier version and the code seems identical to me. I am testing under Firefox 3.5.7, Safari 4.0.4 and IE 6.0. My old version works under these. In the new version, F10 works in Firefox but in Safari when F10 is pressed the "alt" button is pressed as well as F10 being passed back to the server. The "alt" problem does not happen with my old version under Safari nor does it happen in Firefox.

    I wrote the old code, on which the new code is based, several years ago and I am not sure that I really understand what it means now!

    Can anyone please help?

    4) URL TO CODE:

    or, ATTACHED BELOW (see #3 in guidelines below):

    Code:
    <html><head>
    <title>Corporate Organiser II</title>
    </head><body onload="DoOnLoad()" bgcolor="#B0B0B0"><form method="post" action="/cgi-bin/E29RPP.PGM/153518621788124/">
    <SCRIPT LANGUAGE="JavaScript"> var num; var msgt; var shift; document.getElementsByTagName("BODY")[0].setAttribute("onLoad","DoOnLoad()"); javascript:window.history.forward(1); document.onkeydown = showDown; function showDown(evt) {evt=(evt) ? evt : ((event) ? event : null); if (evt) {if (evt.shiftKey) {shift=true;} var nokey=new Array; nokey[0]=112;nokey[1]=113;nokey[2]=114;nokey[3]=115;nokey[4]=116;nokey[5]=117;nokey[6]=118;nokey[7]=119;nokey[8]=120;nokey[9]=121;nokey[10]=122;nokey[11]=123;nokey[12]=033;nokey[13]=034;nokey[14]=166; for(var i=0;i<nokey.length;i++) {if(evt.keyCode==nokey[i]) {buttonClick(i,shift); cancelKey(evt);}}}}
    function cancelKey(evt) {if (evt.preventDefault) {evt.preventDefault();return false;} else {evt.keyCode = 0; evt.returnValue = false;}} if (navigator.appName=="Netscape") {document.addEventListener("keypress",showDown,true);} function buttonClick(i,shift) {var letkey=new Array(); if (shift) {letkey[0]=13;letkey[1]=14;letkey[2]=15;letkey[3]=16;letkey[4]=17;letkey[5]=18;letkey[6]=19;letkey[7]=20;letkey[8]=21;letkey[9]=22;letkey[10]=23;letkey[11]=24;} else {letkey[0]=01;letkey[1]=02;letkey[2]=03;letkey[3]=04;letkey[4]=05;letkey[5]=06;letkey[6]=07;letkey[7]=08;letkey[8]=09;letkey[9]=10;letkey[10]=11;letkey[11]=12;letkey[12]="Up";letkey[13]="Dn";letkey[14]=12;} var buttonname = "BUTTONKeyF" + letkey[i]; document.getElementsByName(buttonname)[0].click();}
    function fd() {document.getElementsByName('BUTTONKeyFEN')[0].click();} function fm(msg) {if (msg=='0') {msgt=" "} else if (msg=='1') {msgt="OR double left click on link to navigate"} else if (msg=='2') {msgt="OR double click to continue"} else if (msg=='3') {msgt="OR double click to Navigate or Single click and then select option"} else if (msg=='4') {msgt="OR double click for details or Single click and click on Navigate"} else if (msg=='5') {msgt="OR single click and select Option"} else if (msg=='6') {msgt="Type . above (you can follow with index name - e.g. .cust*) & ENTER <BR> <B>OR</B> Type .. & ENTER for HOME Page"} else if (msg=='7') {msgt="To continue Sign on, click on or Press ENTER"} else if (msg=='9') {msgt="Or hover over highlighted links or images for instructions"} javascript:document.getElementById('popupText').innerHTML=msgt;}
    function fr(num) {document.getElementsByName('NAM64I')[0].value = num;} function DoOnLoad(){fm(9); document.getElementsByName('NAM64I')[0].focus();} </SCRIPT><STYLE>A:link {color:#FFFF42;text-decoration:none;} A:visited {color:blue;text-decoration:none;} A:hover {color:cyan;text-decoration:none;}</STYLE><PRE><input name="BUTTONKeyFEN" value="Enter" type="submit"><input name="BUTTONKeyFUp" value="Page Up (PgUp)" type="submit"><input name="BUTTONKeyFDn" value="Page Down (PgDn)" type="submit"><input name="BUTTONKeyH" value="" type="submit"><input name="BUTTONKeyF03" value="JUMP BACK (F3)" type="submit" ><input name="BUTTONKeyF05" value="Refresh (F05)" type="submit"><input name="BUTTONKeyF12" value="Return (F12)" type="submit"><input name="BUTTONShort=*E" value="Shortcuts" type="submit"><input name="SPECIALS" value="Style" type="submit"><input name="SPECIALS" value="Tips" type="submit">
    <FONT COLOR="WHITE" SIZE="-0">Corporate Organiser II<FONT COLOR="RED" SIZE="-1"> (An ERROS Application) <TT><FONT COLOR="WHITE" SIZE="-0"> Rob Dixon </B> ERROS plc <BR> <BR> <BR> User personal and business name <BR> <FONT COLOR="BLUE"> name and/or numberČ(Last name, firstname)
    <FONT COLOR="FFFF00"> Our Data</FONT><INPUT TYPE="TEXT" NAME="NAM64I" VALUE="" SIZE=64 MAXLENGTH=64> <A href=# ONMOUSEOVER="fm(6)" ONMOUSEOUT="fm(9)";><B><FONT COLOR=RED SIZE=+1>INDEX</B></A><FONT SIZE=-0> <FONT COLOR="GREEN">Help Level <INPUT TYPE="TEXT" NAME="HLPLVL" VALUE="2" SIZE=1 MAXLENGTH=1><FONT COLOR="RED" >
    <FONT COLOR="BLACK"> # (Number) <INPUT TYPE="TEXT" NAME="REFNOD" VALUE="0" SIZE=09 MAXLENGTH=09>
    <TT><TABLE><TD width="900" BGCOLOR=YELLOW><TT></TT><FONT COLOR="BLACK"> To accept, click on ENTER; else type new ID & click on ENTER<TT></B><FONT COLOR="BLACK"></A> </TD></TR><TR><td bgcolor="yellow" id="popupText"></td></table><FONT COLOR="BLUE">
    <BR><BR><FONT COLOR="RED"> 1 <A href=# ONMOUSEOVER="fm(2)" onDblClick="fr(1); fd()" ONCLICK="fr(1); fm(4)"; onmouseout="fm(9)";>Rob Dixon "Rob" #1000</A> <BR><BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR>
    <input name="BUTTONKeyFEN" value="Enter" type="submit"><input name="BUTTONKeyFUp" value="Page Up (PgUp)" type="submit"><input name="BUTTONKeyFDn" value="Page Down (PgDn)" type="submit"><input name="BUTTONKeyH" value="" type="submit"><FONT COLOR="WHITE"> ERROSV
    <input name="BUTTONKeyF01" value="Help (F1)" type="submit"><input name="BUTTONKeyF02" value="MSG Help (F02)" type="submit"><input name="BUTTONKeyF03" value="JUMP BACK (F3)" type="submit" ><input name="BUTTONKeyF04" value="" type="submit"><input name="BUTTONKeyF05" value="Refresh (F05)" type="submit"><input name="BUTTONKeyF06" value="" type="submit"><input name="BUTTONKeyF07" value="Audit" type="submit" ><input name="BUTTONKeyF08" value="" type="submit"><input name="BUTTONKeyF09" value="Create (F9)" type="submit" ><input name="BUTTONKeyF10" value="Update (F10)" type="submit" ><input name="BUTTONKeyF11" value="Delete (F11)" type="submit" ><input name="BUTTONKeyF12" value="Return (F12)" type="submit">
    <input name="BUTTONKeyF13" value="Report (F13)" type="submit"><input name="BUTTONKeyF14" value="ADD Dupl. (F14)" type="submit" Disabled="Disabled"><input name="BUTTONKeyF15" value="Operate (F15)" type="submit" ><input name="BUTTONKeyF16" value="Options (F16)" type="submit" ><input name="BUTTONKeyF17" value="Tasks (F17)" type="submit" disabled><input name="BUTTONKeyF18" value="Navigate (F18)" type="submit" Disabled="Disabled"><input name="BUTTONKeyF19" value="" type="submit"><input name="BUTTONKeyF20" value="" type="submit" ><input name="BUTTONKeyF21" value="Move (F21)" type="submit" Disabled="Disabled"><input name="BUTTONKeyF22" value="Copy (F22)" type="submit" Disabled="Disabled"><input name="BUTTONKeyF23" value="Messages" type="submit" disabled="disabled"><input name="BUTTONKeyF24" value="" type="submit">
    Last edited by Snookerman; 01-24-2010 at 11:38 AM.

  2. #2
    Join Date
    Jan 2010
    Location
    UK
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Problem now resolved - I rewrote some of the code and found my mistakes. Thanks for looking

    Rob Dixon

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Though I didn't know the answer, I was curious about this. What was the approach that solved the problem?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jan 2010
    Location
    UK
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I hadn't worked out that it was only my single digit function keys that were not working - i.e. F1 to F9. Changing the button names from, for instance, BUTTONKeyF01 to ButtonKeyF1 fixed that. In addition, I had put in key codes of 033 and 034 for page up and page down. Changing those to 33 and 34 fixed those. I have been testing further since I sent my previous post and find that my cancel event coding is not right but hopefully I should soon be able to fix that.

    I didn't explain in my original post that I am using persistent CGI to access and update my AS/400 database.

    Rob Dixon

  5. The Following User Says Thank You to RobDixon For This Useful Post:

    djr33 (01-26-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •