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?

橙三吉。 提交于 2020-12-08 06:33:26

问题


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>

回答1:


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>


来源:https://stackoverflow.com/questions/33339419/phone-links-are-not-working-inside-iframe-though-it-does-work-in-div-in-ios9-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!