Gabbo144
Gabbo144

Reputation: 1

inappbrowser plugin only works on monaca debugger

I am trying to open a link in the system browser in my app built in monaca. Here is the code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home</title>
    <link rel="stylesheet" href="style.css">
    <script src="cordova.js"></script> 
    <script>

        document.addEventListener('deviceready', function() {
            var externalLinks = document.querySelectorAll('a[href^="http"]');

            externalLinks.forEach(function(link) {
                link.addEventListener('click', function(e) {
                    e.preventDefault(); // Impedisce il comportamento predefinito del link

                    var url = this.getAttribute('href'); // Ottiene l'URL dal link
                    cordova.InAppBrowser.open(url, '_system');
                });
            });
        }, false);
    </script>
</head>
<body>
        <a href="example.com">
            <button class="comic-button" style="width: 100%;">***</button>
        </a>
</body>
</html>

In the monaca official debugger when i click the button it opens the link in the external browser. When i build it nothing happens instead.

Upvotes: 0

Views: 24

Answers (0)

Related Questions