【问题标题】:HttpContext.Current.Response.Write not working on IEHttpContext.Current.Response.Write 在 IE 上不起作用
【发布时间】:2014-05-19 07:41:46
【问题描述】:

我正在尝试使用 javascript 捕获 http 并从中删除一些元素
它可以在 chrome 上运行,但不能在 IE 上运行。

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 上运行,我设法对其进行了调试,它转到了代码,但在最终结果中我没有看到脚本,我尝试了不同的脚本,仍然没有运气

【问题讨论】:

    标签: c# iis httpcontext


    【解决方案1】:

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

      obj.removeAttribute('dsplay');
    

    【讨论】:

      猜你喜欢
      • 2016-03-26
      • 2013-08-19
      • 2023-04-04
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-07
      相关资源
      最近更新 更多