用xmlhttp去实现一个新消息到马上弹出提示窗口的功能(类似msn),功能已经有了,现在我想应用到整个系统中而非单独某个页面上,如果不在所有页面做include或者用户控件的形式,其他有什么比较方便的方法吗?

解决方案 »

  1.   

    httpmodule. 
    beginrequest的时候注册js.假设你那个功能封装到一段js代码里面
      

  2.   

    commonmj:具体怎么用,能指点下吗?
      

  3.   


    基类法// 定义基类
    pulic class PageBase : System.Web.UI.Page
    {
          protected override void OnLoad(EventArgs e)
          {           
               ClientScript.RegisterClientScriptInclude(typeof(PageBase), "MyMsgBlock", 
                  (Request.Application == "/" ? "" : Request.Application) + "/js/MyMsg.js"); // MyMsg.js 为你的 js 文件
          }
    }// 继承自定义基类
    // aspx.cs
    public class SomePage : PageBase
    {
           // ...
    }
      

  4.   

    sorry, (Request.Application == "/" ? "" : Request.Application) >>(Request.ApplicationPath == "/" ? "" : Request.ApplicationPath)
      

  5.   

    to:Mark2Win
    是的,js定时请求to:残月
    2.0的方法,我用不了。试用1.1的RegisterClientScriptBlock方法,好象不能直接引用地址,而且这方法也要一个个页面的去改吧!放弃该方法了。另外,tp:commonmj
    我很想知道你的方法。
      

  6.   

    在你的global.asax.cs的request_end事件里加
    protected void Application_EndRequest(Object sender, EventArgs e)
    {Response.Write("<script src='WebIM.js'></script>");
    }