2014-01-15 45 views
0

mydomain.tld的网站中,嵌入了一个包含在otherdomain.tld上承载的表单的iFrame。这两个站点都是在端口80上运行的非SSL。提交嵌入在iFrame中的表单不适用于iOS 7

现在,此表单不会在iOS 7上运行的iPhone 5上提交。我可以在iOS-Simulator中重新选择“iPhone Retina(4英寸64 “)(不会发生在”4英寸“的情况下)。

提交事件被触发(至少如果我通过JavaScript捕获它),但没有根据开发人员工具进行请求。

如果我直接打开iFrame源代码,表单会提交。

我有Internet Explorer中的类似的问题,了解P3P和能够解决的问题发送一个特殊的P3P头:

P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA" 

但对于Safari浏览器中提到的问题,这似乎并不成为问题。

对于Safari和iFrame中的表单有没有任何已知的限制?

+0

看看这里:HTTP: //stackoverflow.com/questions/19667785/iframe-and-mobile-safari-ipad-iphone – Zigglzworth

回答

0

正如我所发现的,问题与在iFrame中使用Cookie相关,这些Cookie触发了iFrame中表单的Spamshield以阻止表单提交。

由于它是一个选择加入的形式,我停用了Spamshield,但我找到了一个解决方案(我没有测试)应该通过提交隐藏表单来工作, iFrame内容。

<script> window.setTimeout(function() { 
if (document.cookie.indexOf('test_cookie=1') < 0) { 
    var  
    name = 'test_cookie', 
    div = document.getElementById(name), 
    iframe = document.createElement('iframe'), 
    form = document.createElement('form'); 

    iframe.name = name; 
    iframe.src = 'javascript:false'; 
    div.appendChild(iframe); 

    form.action = location.toString(); 
    form.method = 'POST'; 
    form.target = name; 
    div.appendChild(form); 

    form.submit(); 
} }, 10); </script> 

来源:https://gist.github.com/daaku/586182