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