简体   繁体   中英

How can I simulate the back button on a samsung device using chrome?

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?

The action performed on pressing the "back" button is dependent on the context. It can be one of the two:

  1. "Back" action in the browser. You can emulate it by calling window.history.back()
  2. 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 with window.open() , so in order to use it the workflow would be: call window.open() -> do stuff -> call window.close() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM