I am using chrome devtools to debug a site running on an android device. In an android device you usually have the "menu" button and the "back" button. How can I emulate a key press to one of these keys using chrome devtools?
Asked
Active
Viewed 6,212 times
1 Answers
14
The action performed on pressing the "back" button is dependent on the context. It can be one of the two:
- "Back" action in the browser. You can emulate it by calling
window.history.back()
- If there are no pages to go back to, then pressing "back" will pop the activity stack and the browser will be closed. I'm not sure how to handle this properly. There is
window.close()
, but it only works in conjunction withwindow.open()
, so in order to use it the workflow would be: callwindow.open()
-> do stuff -> callwindow.close()
.

pablochan
- 5,625
- 27
- 42
-
4Thanks! window.history.back() was what I was looking for. – Tiagojdferreira Feb 09 '15 at 14:14