admin管理员组文章数量:1391937
I have a link in my website that redirects to instagram login to fetch some photos, but that page doesn't work on the in app browser from instagram, on an ios device. My idea is to put a link so the user can click it and be redirected to a page in safari or the default browser, is that possible?
<a id="link" href="">Google</a>
I have a link in my website that redirects to instagram login to fetch some photos, but that page doesn't work on the in app browser from instagram, on an ios device. My idea is to put a link so the user can click it and be redirected to a page in safari or the default browser, is that possible?
<a id="link" href="http://www.google.">Google</a>
- you can put link in App, when user will click, that will redirects to instagram . – Ratnesh Shukla Commented Feb 17, 2017 at 19:28
- Instagram login page doesn't work on In app instagram browser, on ios. – Agu V Commented Feb 17, 2017 at 19:29
- Did you find solution? – kizoso Commented May 18, 2017 at 11:32
- @kizoso no, sorry. – Agu V Commented May 18, 2017 at 19:08
- There's no way to do this AFAIK. – Matthew Dean Commented Jul 18, 2023 at 20:16
2 Answers
Reset to default 1After many experiments, I found a solution that works to open a URL in Safari from embedded browsers on iOS/macOS:
function openInSafari(url) {
// Try both Safari URL schemes for maximum patibility
const xSafariScheme = `x-safari-https://${url.replace(/^https?:\/\//, '')}`;
const legacyScheme = `-apple-mobilesafari-tab:${url}`;
// Try newer scheme first (works on iOS 15/17/18, macOS)
setTimeout(() => { location.href = xSafariScheme; }, 100);
// Then try legacy scheme (works on older iOS, iOS 16)
setTimeout(() => { location.href = legacyScheme; }, 600);
// Fallback to normal URL if neither works
setTimeout(() => { location.href = url; }, 1500);
}
// Usage example - call this when you detect an embedded browser
openInSafari("https://example.");
This will attempt to break out of the in-app browser and open your link in Safari instead.
Credit: I found information about the Safari URL schemes from Christian Tietze's blog where he documents that x-safari-https: works on iOS 15/17/18 and macOS, while the legacy -apple-mobilesafari-tab: scheme works better on older iOS versions and iOS 16.
Not a plete answer, but could be a clue. Just put some blocking js code in the beginning of a html body.
<script>
var str = navigator.userAgent;
var i = str.indexOf("Instagram");
if (i != -1) {
document.write("<a target=\"_blank\" href=\"http://instagram./?nibrowser=no\">Proceed to Sfari</a>");
window.stop();
}
</script>
Some info about Instagram user agent: https://mpulp.mobi/2016/07/12/instagram-user-agent/
On forcing in app browsers to open Safari: https://support.interact.technology/support/solutions/articles/17000003729-how-to-force-a-link-to-open-in-safari-ios-only-
And window.stop() just prevents page load almost in all browsers. Hope it'll help.
本文标签: javascriptEscape instagram in app browser to safariStack Overflow
版权声明:本文标题:javascript - Escape instagram in app browser to safari - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744672727a2618924.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论