我有一个使用Javascript/HTML的Windows 8应用程序,在iframe内我有一个Paypal表单:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="on0" value="Pages">
<select name="os0">
<option value="10">$1.95</option>
<option value="25">$2.95</option>
</select>
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="encrypted" value="[removed]">
<input type="image" src="/btn_buynow_LG.gif" border="0" name="submit" alt="">
</form>
这个表单在所有浏览器中都能很好地工作,包括IE10,但是当从Windows 8应用程序的iframe中提交时,它会将用户引导到Paypal主页。这通常表明表单存在问题。我试过托管Paypal按钮,加密的,未加密的按钮,他们都表现出相同的行为。只有当我在Windows 8应用程序中提交此表单时,它才会转到Paypal.com主页。
我还尝试将每个URL添加到我的清单中作为允许的URL:
<ApplicationContentUriRules>
<Rule Match="http://example.com" Type="include" />
<Rule Match="http://*.example.com" Type="include" />
<Rule Match="http://paypal.com" Type="include" />
<Rule Match="http://*.paypal.com" Type="include" />
<Rule Match="https://paypal.com" Type="include" />
<Rule Match="https://*.paypal.com" Type="include" />
</ApplicationContentUriRules>
我尝试添加/删除sandbox属性并添加所有属性组合,如下所示:
<iframe sandbox="allow-same-origin allow-top-navigation allow-forms allow-scripts allow-popups" src="http://example.com/paypalbtn.html"></iframe>
如果我移除target="_blank"
,那么Windows 8应用程序将导航到黑屏并挂起。我被迫按alt-tab键并关闭应用程序。我认为这是表单POST到另一个进程中的新窗口的问题。
如何在Windows 8应用程序的框架内启动Paypal ?
是否需要表单POST ?我现在意识到一个表单GET工作
当从Windows 8应用程序中的iframe启动时,Paypal将阻止表单POST到新窗口。结果是您看到Paypal主页而不是购买订单表单。
我可以确认,简单地将表单方法切换到GET
并使用target="_blank"
完全没有问题:
<form action="https://www.paypal.com/cgi-bin/webscr" method="get" target="_blank">
在iframe内解决这个问题的另一种方法是在文本或图像周围使用标准锚标记,并手动创建URL,如下所示:
<a href="https://www.paypal.com/cgi-bin/webscr?custom=[custom info]&item_name=[URL encoded name]&item_number=[num]&amount=9.95¤cy_code=USD&cmd=_xclick&business=[paypal email address]&return=[URL encoded URL]">Buy Now</a>
这个答案的功劳在这个关于Paypal链接的页面,而不是按钮。
我认为paypal不支持iframe。他们最可能使用这个:
交叉形架的选择
它允许他们检测页面是否在iframe中呈现,如果是,阻止它加载。(也就是显示空白页)就像你正在经历的。
这是没有办法的
我在PayPal和Windows Store应用程序中遇到了类似的问题。我刚刚在这个线程中发布了我对问题的解决方案:
带有弹出窗口的Windows Store HTML应用程序