我正在创建一个3D Secure表单,如果要求用户将它们重定向到3D Secure Banks的网关。
我遇到的问题是以下脚本:
<SCRIPT LANGUAGE='Javascript' >
<!--
function OnLoadEvent()
{
document.mainform.submit();
}
//-->
</SCRIPT>
似乎需要在bodyOnload =“OnloadEvent”上加载
Unfortunatley我无法修改页面的body标签。所以我需要在PHP脚本的上下文中调用时加载代码..
代码是:
} else if($result_arr['valid'] == 'true' && ($mpistatus == '200')) {
$threedurl = urldecode($result_arr['acs_url']);
$paymentauth = $result_arr['PaReq'];
$mdcode = $result_arr['MD'];
echo
"<form name='mainform' action='$threedurl' method='POST'>
<center>
<h1>Processing your 3D Secure Transaction</h1>
<h3>Please click Submit to continue
the processing of your 3D Secure
transaction.</h3>
<input type='submit' value='Submit'>
</center>
<input type='hidden' name='PaReq' value='$paymentauth'>
<input type='hidden' name='TermUrl' value=''>
<input type='hidden' name='MD' value='$mdcode'>
</form>
<SCRIPT LANGUAGE='Javascript' >
<!--
function OnLoadEvent()
{
document.mainform.submit();
}
//-->
</SCRIPT>
";
}
我是否可以在脚本中调用时加载表单,如果是这样的话......怎么样??
答案 0 :(得分:1)
当然可以!只需删除周围的函数def,代码就会立即执行:
<SCRIPT LANGUAGE='Javascript' >
<!--
document.mainform.submit();
//-->
</SCRIPT>
答案 1 :(得分:1)
只需将其添加到窗口的onload方法中吗?
if (window.addEventListener) // W3C standard
{
window.addEventListener('load', myFunction, false); // NB **not** 'onload'
}
else if (window.attachEvent) // Microsoft
{
window.attachEvent('onload', myFunction);
}