简体   繁体   English

如何使用Chrome在三星设备上模拟后退按钮?

[英]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. 我正在使用chrome devtools调试在android设备上运行的网站。 In an android device you usually have the "menu" button and the "back" button. 在android设备中,您通常具有“菜单”按钮和“后退”按钮。 How can I emulate a key press to one of these keys using chrome devtools? 如何使用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() 您可以通过调用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() . window.close() ,但它只能与window.open()结合使用,因此要使用它,工作流程为:调用window.open() ->做东西->调用window.close()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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