Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Fresno Cali
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Hot keys with alt or ctrl mod. to link to url ?

    I need some help with an issue that for the last week has been my nighmare. I have
    been programming html for two years and php/mysql for about eight monthes, so I'm pretty new at this. Anyways, I have been searching and
    reading and trying very hard to implement java hotkeys into a simple html page. I have found about five ways to do the hot key itself ( that
    work). Although I wouldn't say I have a very strong grasp of which thing in the script are variables, which things are functions and which
    things are java commands. Anyways, I have also found some applets that test wether a modifier is present.
    I am having serious trouble putting the two together. This is the closest I've gotten:

    <script language="JavaScript1.2">
    if (document.layers)
    document.captureEvents(Event.KEYPRESS)
    function backhome(e)
    {
    if (document.layers)
    {
    if (evt.isAltDown())
    {
    if (e.which==117)
    window.location="http://www.internetfresno.com/madera/index.php?app1=takemsg&login=<?echo$login;?>"
    }
    }
    else if (document.all)
    {
    if (evt.isAltDown())
    {
    if (event.keyCode==117)
    window.location="http://www.internetfresno.com/madera/index.php?app1=takemsg&login=<?echo$login;?>"
    }
    }
    }
    document.onkeypress=backhome

    </script>


    But it doesn't work.
    I would like this to work in Internet explorer 5 and Netscape 4.75 would be a bonus, but not necessary. All I really need is for when the user
    presses either Alt-U or Ctrl-U or even a function key for an a href to fire a simple link. The cursor is positioned in a text box, so a normal key won't do.
    I've poured through page after page of java scripts. I
    would be in your debt if you could help me with this.
    Enjoy my site. www.scubanaked.com (it's not porn)
    and email me at brian@scubanaked.com
    Thank you
    Brian Kempe
    Fresno California

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    document.onkeypress = function(event) {
    if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u') {
    // do something for CTRL-U
    }
    }

    I believe should accomplish what you want in NS6+ and IE4+.

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Fresno Cali
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tried it... Need help

    I am trying the following in IE 5.5 and am not getting anything for Ctrl-u:

    <script language="JavaScript1.2">


    document.onkeypress = function(event) {
    if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u') {
    window.location="http://www.internetfresno.com/madera/index.php?app1=useradmin"
    }
    }

    </script>

    What am I missing.
    http://www.internetfresno.com/madera/shorthotkey3.html

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Oops:

    document.onkeypress = function(event) {
    if (!event && window.event) event = window.event;
    if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u') {
    window.location="http://www.internetfresno.com/madera/index.php?app1=useradmin"
    }
    }

    I think that should work.

  • #5
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Fresno Cali
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    it still doesn't work

    I uploaded this
    <script language="JavaScript">
    document.onkeypress = function(event)
    {
    if (!event && window.event) event = window.event;
    if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u')
    {
    window.location="http://www.internetfresno.com/madera/index.php?app1=useradmin"
    }
    }
    </script>
    www.internetfresno.com/madera/shorthotkey3.html
    I'm at a loss
    But, believe me I appreciate your attention to my deliema
    Brian : )
    Last edited by Scubanaked; 08-19-2002 at 05:26 PM.

  • #6
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Fresno Cali
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I got the answer I needed Thanks

    <a href="http://www.url.com" onfocus="window.location='http://www.url'" accesskey="A">
    <u>A</u>nother link
    </a>

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can also check this page for more info


  •  

    Posting Permissions

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