0

I'm trying my hand at responsive web design. So a navigation menu collapses into a drop down menu when on a small screen. The user can touch a button to see the menu. Right now, just the button toggles the drop down visibility. I want to be able to just press the back key on a phone or touch outside to hide it. Any hints on how this can be achieved would be helpful.

Utkarsh Sinha
  • 3,295
  • 4
  • 30
  • 46
  • 1
    Try this answer: http://stackoverflow.com/questions/6610022/jquery-close-div-by-clicking-anywhere-apart-from-the-div-itself – kierzniak Oct 24 '12 at 20:06

1 Answers1

1

The BACK button in a mobile browser is just like that in a desktop app: it is not directly scriptable.

If you want an action on clicking "outside" an element you will have to sniff the cursor position on the click event and determine where the click occurred yourself. Alternately you can listen to all click events and determine the tag that was clicked on.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176