How can I detect when a user clicked a particular button of a website loaded inside the webview of my app?

Viewed 19

I am loading Amazon website inside the webview of my app and i want to show a toast message when user clicks the Buy Now button in that loaded website. What is the way to do perform this task using javascript or any other method available.

1 Answers

Try this maybe if you just want to show a message/alert

<script>

  function showAlert() {
    alert ("Hello world!");
  }

</script>

And set the buttons onCLick property be this function. For eg.

function myFunction() {
  alert("I am an alert box!");
}
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Alert</h2>

<button onclick="myFunction()">Try it</button>



</body>
</html>

Related