HttpContext.Current.Response.Write不能在IE上工作

本文关键字:IE 工作 不能 Current Response Write HttpContext | 更新日期: 2023-09-27 18:04:04

我试图捕获一个http,并从它使用javascript删除一些元素

void context_EndRequest(object sender, EventArgs e)
{
    HttpContext context = ((HttpApplication)sender).Context;
    if (context.Request.Url.AbsolutePath.Contains(@"/account/"))
    {        
        HttpContext.Current.Response.Write(@"<script type='text/javascript'> document.getElementById('swtch').style.display = 'none';</script>");        
    }
}

我试着:

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Write(@"<script type='text/javascript'> document.getElementById('swtch').style.display = 'none';</script>"); 
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();

它写脚本,但也它清除整个html和对象,我正在寻找的是不存在了。

该网站是在IIS上运行的,我设法调试它,它去代码,但在最后的结果我没有看到脚本,我尝试了不同的脚本,仍然没有运气

HttpContext.Current.Response.Write不能在IE上工作

我知道我的答案太迟了,但也许它会有所帮助!你可以试试:

  obj.removeAttribute('dsplay');