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

javascript - Phone links are not working inside iframe though it does work in div in iOS9 web. how to make phone links make work

programmeradmin3浏览0评论

Hi I was trying phone links inside iframe in iOS9. Phone application doesn't open up in safari in iOS9. When i tried same link inside then it is working there.

I was trying below anchor tag. This code opens up phone application when put inside div. But same code doesn't work inside iframe. Please suggest how does it make to work inside iframes as well?

Please use below code to see phone link outside iframe

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

Please use below code to verify phone link inside 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>

Hi I was trying phone links inside iframe in iOS9. Phone application doesn't open up in safari in iOS9. When i tried same link inside then it is working there.

I was trying below anchor tag. This code opens up phone application when put inside div. But same code doesn't work inside iframe. Please suggest how does it make to work inside iframes as well?

Please use below code to see phone link outside iframe

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

Please use below code to verify phone link inside 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>
Share Improve this question edited Nov 2, 2015 at 6:25 Suresh Dube asked Oct 26, 2015 at 6:07 Suresh DubeSuresh Dube 1131 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 23

Today I had the same problem and found a simple solution for it. Just use target="_parent" and the Links will also work in safari on iOS9.

<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>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论