Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open mobile chrome browser with javascript or html

I have two questions.

//// I want this ////

I want to open chrome browser with url on other android mobile webapp(ex naver, firefox, etc...) with using javascript or html

so example) if user click MysiteButton on mobile web app, then open android device mobile chrome browser with redirect url(on chrome).

what should i do.

//// Question List ////

  1. i found that I should use deeplink or intent but i don't know android mobile chromebrower's intent url or Scheme url. what is android mobile chromebrower's intent url. how to get. ( i used window.location.href = "market://detail?id=com.android.chrome"; but not worked)

  2. when i use deeplink or intent, how to redirect url on chrome at the same time open chrome

like image 933
minsu lee Avatar asked Oct 11 '25 18:10

minsu lee


2 Answers

For Android:

<a href="intent:https://yourwebsite.com#Intent;end" target="_blank">Open Browser</a>

Note: This solution will open default browser (if its set, if no default browser set, it will show list of browsers which supports opening url)

Make sure that, the click is generated by user (Not Javascript) to test this. Some browsers wont open if its NOT called by user.

like image 67
John Avatar answered Oct 14 '25 12:10

John


I was looking for the answer too as I've tried to send my users from unsupported browsers (for ex: Facebook browser) to chrome.

Unfortunately, John's solution didn't work for me but it pointed in the right direction.

What works for me:

<a href="intent://mysite.com#Intent;scheme=https;package=com.android.chrome;end">
    Click to open on Chrome
  </a>

Explanation

I've found a good explanation at https://branch.io/glossary/chrome-intents/ , but to sum it up:

Split it to 3 vars:

URI: the name of the site (ex: google.com), and notice its without the UriSchemes.

UriSchemes: HTTP / https (you can read more about it at https://www.w3.org/wiki/UriSchemes)

PACKAGE: the package of the app we want to send the intent to, in our case its com.android.chrome

now you can just insert them in the code below

<a href="intent://URI#Intent;scheme=UriSchemes;package=PACKAGE">
    Click to open on Chrome
  </a>
like image 26
Avishai V. Avatar answered Oct 14 '25 11:10

Avishai V.