Share via


Opening link from mobile app in external browser

Question

Sunday, May 9, 2021 1:23 PM

I am a web developer working in ASP. NET for the first time in a new position. I was tasked with creating a link which would lead from a razor web page which is displayed within a in-mobile-app browser to an external link, which we would like opened on the user's system browser. This is something that it sounds as though no one on my team has experience with, since the mobile app dev is new to our project. I have tried a couple of options, but am not having any luck. Here are the attempts I have made, and the results:

<a href = "@externalURL" target= "_blank" >
    <button type="button" class="btn btn-primary">
        Button Name
    </button>
</a>

This has a result of the button leading to the link within the mobile app browser. I want the link to lead me to a new window within the phone's default browser (i.e. Safari)

<a href = "#" onclick= "window.open('@externalURL', '_system');" >
    <button type="button" class="btn btn-primary" disabled="@(!_acknowledged)">
        Button Name
    </button>
</a>

When tested on desktop, this does the trick (although it does leave the original page with a default page), but when tested within mobile, it once again does not open a new browser, or even the window within the in-app browser.

Does anyone know what I may be doing wrong here? This seems like it should be trivial, but I have not been able to find the resources from searching Google or StackOverflow

All replies (1)

Sunday, May 9, 2021 4:40 PM

Hi,

If you ask in a forum dedicated to your mobile app technology you'll reach people using that rather than here general web developers.

From a search it seems you are perhaps trying to use something such as GitHub - apache/cordova-plugin-inappbrowser: Apache Cordova Plugin inappbrowser 

It is also possible that this is not needed and that all urls being apart of your app are opened inside the mobile app while external links are opened in an external browser.

What happens if you test first with a link such as https://www.google.com/ ?

Edit: I never really used that. I'm just using this occasion to lean something new (I'm currently looking at PWAs where it seems to depend on scope - Web app manifests | MDN (mozilla.org))