How to go back page when back button of android is pressed

How to go back page when back button of android is pressed using javascript

You can listen to the backbutton event :slight_smile:

document.addEventListener('backbutton', doSomething, false);

function doSomething(e) {
    // do something
    console.log("Back button pressed!");

    // prevent the default Android back button behavior!

how i apply this to web page ??

Please sort out this
how to go index.html or any other page by back button of android device … please help u r my life line now

You could add this code inside your script tags on the HTML page you are on. If you don’t have a page, you can try this:


please kirupa sort out my index.html problem by pressing back button of android device …please tell me the code

I can’t do the work for you, since I don’t even know what the work is. The code I provided will allow you to check for the back button being pressed. If you want to next go to index.html, you can use the following:

window.location.href = "index.html";

i exactly use this but how do i trigger it on back button

When you click the back button on the device, the code will run. Is it not working when you try?

yes it doesnot work man when i hit the back button