如何强制在移动操作系统的本机浏览器中打开链接?

问题描述 投票:0回答:1

我正在尝试重新创建服务的行为https://allmylinks.com/。我需要一个适用于 iO 和 Android 的可行解决方案。我想在我的个人简介中为我的客户放置一个链接,用于我的其他社交媒体帐户。此链接应(强制)在本机/标准移动浏览器中打开,例如适用于 ios 的 Safari。

我尝试通过伪造 pdf 下载来解决这个问题,这是在一些旧帖子中建议的。这不起作用。我进一步尝试使用 URI 方案,具体取决于所使用的操作系统。也没起作用

javascript html web mobile instagram
1个回答
0
投票

要强制在移动操作系统的本机浏览器中打开链接,您可以使用 HTML 中的 target="_system" 属性作为锚点 () 标记。该属性提示设备在系统默认浏览器中打开链接。以下是实施方法:

<a href="https://example.com" target="_system">Open Link</a>

单击此代码将在设备的本机浏览器中打开链接“https://example.com”。

对于 Instagram 等移动应用程序中的特定用例,您可以将此链接放置在您的个人简介中,当用户单击它时,它应该在设备的默认浏览器中打开。

这是代码的细分:

<a>: This is the anchor tag used to create a hyperlink.
href="https://example.com": This specifies the URL that the hyperlink points to.
target="_system": This attribute specifies the browsing context in which the linked resource should open. In this case, "_system" refers to the system's default browser.

这应该适用于 iOS 和 Android 设备。请务必在不同设备上进行测试以确保兼容性。

© www.soinside.com 2019 - 2024. All rights reserved.