最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Instagram links open in-app browser instead of externalnative browser - Stack Overflow

programmeradmin4浏览0评论

If I have a link in my profile, the link opens up an in-app browser either from iOS or Android. Is it possible to open up an external browser instead? Possibly in my own site, if I can detect if user uses mobile, open native browser? Perhaps this is a solution with javascript?

The issue is because users who are logged into my site, and then click on the link within Instagram the in-app browser doesn't keep the user logged in.

If I have a link in my profile, the link opens up an in-app browser either from iOS or Android. Is it possible to open up an external browser instead? Possibly in my own site, if I can detect if user uses mobile, open native browser? Perhaps this is a solution with javascript?

The issue is because users who are logged into my site, and then click on the link within Instagram the in-app browser doesn't keep the user logged in.

Share Improve this question asked Nov 8, 2018 at 22:23 hellomellohellomello 8,59742 gold badges154 silver badges310 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

That’s possible and simple!
you must cheat the Instagram’s in-app browser. The weakness point of Instagram’s in-app browser is file downloading. When you ask it to download a file, it invokes an external browser and this is our golden key.

You first need to check which browser has your customer e to your website with.
In other words:

<script>
   if(navigator.userAgent.includes("Instagram")){
       window.location.href = "https://mywebsite./DummyBytes";
   }
</script>

Then, implement the DummyBytes API. This API returns a different response based on the viewer’s browser. If the viewer’s browser is Instagram’s in-app browser, it will return some dummy bytes as a file, otherwise it will return a response that redirects the viewer’s browser to your main website (mywebsite.)

<?php
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    if (strpos($userAgent, 'Instagram')) {
        header('Content-type: application/pdf');
        header('Content-Disposition: inline; filename= blablabla');
        header('Content-Transfer-Encoding: binary');
        header('Accept-Ranges: bytes');
        @readfile($file);
    }
    else{
        header('Location: https://halterapp.');
    }
?>

If you want more guidance, see link below:
Opening of your website in the viewer’s external browser automatically instead of Instagram’s in-app browser

发布评论

评论列表(0)

  1. 暂无评论