在网页提交的JavaScript事件 [英] Javascript event on page postback

查看:122
本文介绍了在网页提交的JavaScript事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有被触发回发任何JavaScript事件?

Is there any javascript event which is triggered on postback?

如果不是,我怎么能后或网页提交之前立即运行客户端code?

If not, how can I run client side code immediately after or before a page postback?

非常感谢,
布鲁诺

Many thanks in adavance, Bruno

推荐答案

我相信你正在寻找的是的 Sys.WebForms.PageRequestManager BeginRequest事件

I believe what you are looking for is the Sys.WebForms.PageRequestManager beginRequest Event

摘录:

在BeginRequest事件中的处理之前募集
  异步回送启动并回传被发送到服务器。
  您可以使用此事件来调用自定义脚本设置请求头
  或启动通知用户回发是一个动画
  正在处理中。

The beginRequest event is raised before the processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to call custom script to set a request header or to start an animation that notifies the user that the postback is being processed.

code样品:<​​/ STRONG>(从链接)

Code Sample: (From the link)

<script type="text/javascript" language="javascript">
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    function BeginRequestHandler(sender, args)
    {
        var elem = args.get_postBackElement();
        ActivateAlertDiv('visible', 'AlertDiv', elem.value + ' processing...');
    }
    function EndRequestHandler(sender, args)
    {
        ActivateAlertDiv('hidden', 'AlertDiv', '');
    }
    function ActivateAlertDiv(visstring, elem, msg)
    {
        var adiv = $get(elem);
        adiv.style.visibility = visstring;
        adiv.innerHTML = msg;                     
    }
</script>

我希望帮助。该 PageRequestManager 类似乎很少知道关于小和利用。

I hope that helps. The PageRequestManager class seems to be little known about and little utilized.

这篇关于在网页提交的JavaScript事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆