简体   繁体   English

如何使用纯Javascript捕获Webview应用中的后退箭头按钮?

[英]How to capture back arrow button in webview app using plain Javascript?

I want to add an event when user clicks on the back arrow button in webview using but I couldn't able to find any particular article. 当用户单击Webview中的后退箭头按钮时,我想添加一个事件,但找不到任何特定的文章。 I am not using react native, just want to do using plain javascript. 我没有使用本机反应,只想使用纯JavaScript。

You should be able to use HTML 5 popstate() function. 您应该能够使用HTML 5 popstate()函数。 For example: 例如:

window.onpopstate = func;

function func() {
   //do your stuff here
}

You can also use an anonymous function as such: 您还可以这样使用匿名函数:

window.onpopstate = function() {
   //do stuff here
}

However, when you say webview, are you talking about JavaFX webview, as in, something external from the normal html/css/js? 但是,当您说Webview时,您是在谈论JavaFX Webview,例如,在普通html / css / js外部的东西吗? If so, I would assum this popstate should still work. 如果是这样,我想这个popstate应该仍然可以工作。

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

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