仅在达到时加载

发布于 2024-12-09 17:44:29 字数 1591 浏览 0 评论 0原文

我正在创建一个 3D 安全表单,如果用户需要将其重定向到 3D 安全银行的网关。

我遇到的问题是以下脚本:

<SCRIPT LANGUAGE='Javascript' >
<!--
function OnLoadEvent()
{
document.mainform.submit();
}
//-->
</SCRIPT>

似乎需要在 bodyOnload="OnloadEvent" 上加载

不幸的是,我无法修改页面的正文标记。因此,我需要在 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>
            ";
      }

我可以让它仅在脚本内调用时加载表单吗?如果可以,如何实现?

I am creating a 3D Secure form, which if the user is required to re-directs them to the 3D Secure Banks' gateway.

The issue I have is that the following script :

<SCRIPT LANGUAGE='Javascript' >
<!--
function OnLoadEvent()
{
document.mainform.submit();
}
//-->
</SCRIPT>

Appears to need to be loaded on bodyOnload="OnloadEvent"

Unfortunately I can't modify the body tags of the page. So I need the code to load when its called in context of the PHP Script.

The code for that is:

} 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>
            ";
      }

Can I get it to load the form only when called within the script, if so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情 2024-12-16 17:44:29

当然 !只要去掉周围的函数def,代码就会立即执行:

<SCRIPT LANGUAGE='Javascript' >
<!--
document.mainform.submit();
//-->
</SCRIPT>

Sure ! Just remove the surrounding function def, and the code will be executed right away:

<SCRIPT LANGUAGE='Javascript' >
<!--
document.mainform.submit();
//-->
</SCRIPT>
芯好空 2024-12-16 17:44:29

只需将其添加到窗口的onload方法中即可?

if (window.addEventListener) // W3C standard
{
  window.addEventListener('load', myFunction, false); // NB **not** 'onload'
} 
else if (window.attachEvent) // Microsoft
{
  window.attachEvent('onload', myFunction);
}

Just add it to the onload method of the window ?

if (window.addEventListener) // W3C standard
{
  window.addEventListener('load', myFunction, false); // NB **not** 'onload'
} 
else if (window.attachEvent) // Microsoft
{
  window.attachEvent('onload', myFunction);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文