【问题标题】:Phone links are not working inside iframe though it does work in div in iOS9 web. how to make phone links make work in iOS9 safari?电话链接在 iframe 中不起作用,尽管它在 iOS9 Web 中的 div 中起作用。如何使电话链接在 iOS9 Safari 中起作用?
【发布时间】:2016-01-25 04:17:25
【问题描述】:

您好,我在 iOS9 的 iframe 中尝试了电话链接。手机应用程序在 iOS9 的 safari 中无法打开。当我在里面尝试相同的链接时,它在那里工作。

我正在尝试使用锚标记。此代码在放入 div 时打开电话应用程序。但是相同的代码在 iframe 中不起作用。请建议它如何在 iframe 中工作?

请使用以下代码查看 iframe 外的电话链接

<a href = "tel://1-408-555-5555">1-408-555-5555</a>

请使用以下代码验证 iframe 中的电话链接。

<iframe  id = "test" style = "border:none;"></iframe>
<script>
var iframe = document.getElementById("test");
var iDoc = iframe.contentDocument;
iDoc.write('<a href = "tel://1-408-555-5555">1-408-555-5555</a>');
</script>

【问题讨论】:

    标签: javascript web ios9


    【解决方案1】:

    今天我遇到了同样的问题,并找到了一个简单的解决方案。只需使用 target="_parent" 链接也可以在 iOS9 上的 safari 中使用。

    <iframe  id = "test" style = "border:none;"></iframe>
    <script>
    var iframe = document.getElementById("test");
    var iDoc = iframe.contentDocument;
    iDoc.write('<a target="_parent" href = "tel://1-408-555-5555">1-408-555-5555</a>');
    </script>
    

    【讨论】:

    • 感谢您的帮助。这确实有效。就我而言,有多个父 iframe,因此我使用 target = "_top" 作为锚标记。
    • 当我使用 target="_parent" 它适用于 tel 但 mailto 不起作用。知道如何解决吗?
    • 我有一个非常相似的问题,这个问题解决了我的问题。谢谢! stackoverflow.com/questions/65061855/…
    猜你喜欢
    • 1970-01-01
    • 2013-12-13
    • 2012-01-04
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多