Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9150647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:38:21+00:00 2026-06-17T11:38:21+00:00

I created the following event to Android’s Back button ( PhoneGap 2.2.0): document.addEventListener(backbutton, function

  • 0

I created the following event to Android’s Back button (PhoneGap 2.2.0):

document.addEventListener("backbutton", function (e) {
    //Do Something
}, false);

I have the following link that takes me to an external site from application

My Link

I override the back button event and as soon as I pass inside the app to another link the event is not canceled.. and since another link not know cordova he can not even access to this event.

So I have to cancel it completely!

How I do it…?

When I press the back button I get the following error message in the log:

Uncaught ReferenceError: cordova is not defined at :1

and nothing happens ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:38:22+00:00Added an answer on June 17, 2026 at 11:38 am
    function onBackKey() {
        console.log("I've caught a back key");
    
        // We are going back to home so remove the event listener
        // so the default back key behaviour will take over
        document.removeEventListener("backbutton", onBackKey, false);
    
        // Hide the current dive and show home
        document.getElementById(cur).style.display = 'none';
        document.getElementById('home').style.display = 'block';    
        cur = 'home';
    }
    
    function goToDiv(id) {
        // We are moving to a new div so over ride the back button
        // so when a users presses back it will show the home div
        document.addEventListener("backbutton", onBackKey, false);
    
        // Hide home and show the new div
        document.getElementById('home').style.display = 'none';
        document.getElementById(id).style.display = 'block';
        cur = id;
    }
    

    place html tags

     <div id="home">Back Button Home<br/><a href="javascript:goToDiv('div1')">Div One</a><br/><a href="javascript:goToDiv('div2')">Div Two</a></div>
    

    Please find below link for the detailed answer

    https://gist.github.com/955496

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created following thing in android using android compatibility support package Basically i
I have created following rule in the .htaccess file located at the root of
I need to have the URL like photos/13/rate => I have created following routing
I created the following function to simplify a piece of particularly complex code. CREATE
I created the following interface: <?php interface Action { public function execute(\requests\Request $request, array
I have created an application that creates notifications, using the following code: // notification
I just created a new project on Android and it shows the following: I
I am trying to learn about the Service class in Android. I have created
I have the following code: package com.example.top_tech_deals; import android.app.Activity; import android.content.Intent; import android.media.MediaPlayer; import
Background: The Cordova phonegap 2.2 application running on Android allows listening to the backbutton

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.