- 1

how to detect the back button being pressed on the web to return to the previous page without the button on the web

17th Nov 2019, 1:43 AM
Avirur Rahman
Avirur Rahman - avatar
7 Answers
+ 6
In the callback function of keydown event, the parameter is event, compare event.keyCode with the keycode value of keyboard backspace button. Read: https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event and https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
17th Nov 2019, 2:00 AM
Gordon
Gordon - avatar
+ 3
on keydown keyCode
17th Nov 2019, 1:46 AM
Gordon
Gordon - avatar
+ 3
Avirur Rahman Did you mean the backspace button on keyboard, or back button of the browser? I think you meant the latter option but please clarify this : )
17th Nov 2019, 3:25 AM
Ipang
+ 3
Avirur Rahman Okay bro, thanks for clarification 👍 I asked because your question said "back button being pressed on the web to return to the previous page" 😁
17th Nov 2019, 3:37 AM
Ipang
+ 2
Ipang I mean the backspace button😄
17th Nov 2019, 3:31 AM
Avirur Rahman
Avirur Rahman - avatar
+ 2
Ipang well, before returning to the previous page I want to display a message like an alert / confirm
17th Nov 2019, 3:55 AM
Avirur Rahman
Avirur Rahman - avatar
+ 1
Gordon how to apply it give me an example
17th Nov 2019, 1:52 AM
Avirur Rahman
Avirur Rahman - avatar