Inappbrowser using Phonegap build

Asked

Viewed 61 times

2

I have an application that runs on mobile compiled in PG build Cli 5.2.0 In this app I have some external links to open. I implemented inappbrowser to be able to close the open browser and return to the app. however there are several different links. Is there any way I can do a function without the specific link and only specify on the button when I call the function? so I don’t have to do a function for each different link. Ex: I am using.

<head>
    <!-- o script esta rodando no cabeçalho -->
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    function face() {
         var ref = window.open('http://facebook.com', '_blank', 'location=yes');
    }

    </script>

<body>

the button is in the body of the app and needs to have several buttons of this with different links...

   <li><button onclick="face()">Pagina do face</button></li>
  • You can put the link here onclick="face(link...)" and then do inside the function ... ction face(link) {window.open(link, ... Is that what you want? Notice that yours </head> is missing.

  • Vlws brother I believe this will solve my problem, after the link came out with ... there in windows open, what goes after?

  • Can Sergio help where I’m going wrong?... <head> <script type="text/javascript" charset="utf-8" src="Cordova.js"></script> <script type="text/javascript" charset="utf-8"> Function face(link) { var ref = window.open('link', '_Blank', 'Location=yes'); } </script> </head> In the body... <button onclick="face('https://facebook.com')">You have offered</button>

  • Thanks brother worked out I found the error... was using 'link' within windows.open... and no need to ' '

1 answer

0

You can use the same function but pass as argument the link you want to open.

So in HTML you can have:

<li><button onclick="face('http://um.link.com')">Pagina do Um</button></li>
<li><button onclick="face('http://outro.link.com')">Pagina do Outro</button></li>

and the function would be like this:

function face(meuLink) { 
    window.open(meuLink, '_blank', 'location=yes'); 
}

I called meuLink variable, but you can name it whatever you want.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.