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 5963357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:14:23+00:00 2026-05-22T19:14:23+00:00

Does anyone know a way to detect if a button with this, code below,

  • 0

Does anyone know a way to detect if a button with this, code below, in the source of the webpage is pressed in my apps webview?

html source of button:

<input id="testBtn" name="testBtn" type="button" value="Test Button" 
class="button" onclick="test.run(this.id,'onclick');return false;" 
onkeydown="test.run(this.id,'onkeydown');return false;" title="Test Button">

and then make a toast?

P.s. I cant change html code it is not my site

  • 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-05-22T19:14:24+00:00Added an answer on May 22, 2026 at 7:14 pm

    that will be easy just define your Javascript Interface

    final class jocJavaScriptInterface {
        jocJavaScriptInterface() {
        }
        String myEvent;
        public void run(int id,String event) { //run method defined into your html.
            this.myEvent = event;
            mHandler.post(new Runnable() {
                public void run() {
            Toast.makeText(getApplicationContext(),myEvent + " my ButtoN!", Toast.LENGTH_LONG).show();
                }
            });
        }
    }
    

    Add the Javascript Interface to you webview

        WebContent.addJavascriptInterface(new jocJavaScriptInterface(), "test");        
        WebContent.loadUrl("http://www.foo.com/Androidtest.html"); //load your Page with the button...
        WebSettings webSettings = WebContent.getSettings();
        webSettings.setSavePassword(false);
        webSettings.setSaveFormData(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does anyone know a good way to, in code, detect if the app is
Does anyone know a way to detect the older set of devices: iPod touch
Does anyone know of a way to detect when the last time a Microsoft
Does anyone know of a way to detect if a remote app has failed/crashed?
Does anyone know what would be the best way to detect which version of
Does anyone know a way to make an asp button... <asp:button runat=server>Button1</asp:button> resemble an
Does anyone know a way to auto-generate database tables for a given class? I'm
Does anyone know a way to find out programatically which physical disk holds a
does anyone know a way to call a generic method of a base class
Does anyone know a way to open up an instance of the operating system

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.