【问题标题】:Mobile links in an Iframe and IOSiframe 和 IOS 中的移动链接
【发布时间】:2016-06-01 16:16:53
【问题描述】:

我今天试图从我的一个在 iframe(相同域)中运行的 web 应用打开一个移动链接。

Apple 似乎无法识别这些链接?

https://plnkr.co/edit/9Rp87NcVi9Kr4MGDgIwL?p=preview

正文文件

<html>
    <body>
        <a href="tel:1-888-888-1212">1-888-888-1212</a>
        <iframe src="iframe.html"></iframe>
    </body>
</html>

iframe.html

<body>
    <a href="tel:1-877-877-2323">1-877-877-2323</a>
</body>

在下面的 plunkr 中,我做了一个小例子。 我的本地计算机可以识别这些链接,我的多个 android 设备也是如此。虽然对于 IOS,没什么可做的,它只适用于不在 iframe 中的链接。

有人遇到过类似的问题,或者知道这个问题的解决方案吗?

【问题讨论】:

    标签: html ios iphone iframe


    【解决方案1】:

    通过使用脚本从 iframe 中选择父文档,它应该可以工作。试试这个:

    edit 将“target="_parent" 添加到锚点是查看此答案的人的解决方案。

    过时的答案:

    <iframe  id="test" src="iframe.html"></iframe>
    <script>
    var iframe = document.getElementById("test");
    var iDoc = iframe.contentDocument;
    iDoc.write('<a target="_parent" href="tel://1-888-888-1212">1-888-888-1212</a>');
    </script>
    

    【讨论】:

    • 实际上没有必要将它放在整个脚本标签中。仅将 target="_parent" 添加到我的锚标记即可解决此问题谢谢!
    • 很高兴有帮助,我的框架在 zend 中,我不得不使用这个脚本,很抱歉!
    • 这是否适用于跨域?对于 iFrame 中显示的页面,只需添加 target="_parent" 即可?
    猜你喜欢
    • 1970-01-01
    • 2013-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 1970-01-01
    • 1970-01-01
    • 2012-07-28
    相关资源
    最近更新 更多