2014-05-19 161 views
1

我試圖捕獲一個HTTP並從它刪除一些元素使用javascript
其工作在鉻但不能在IE上工作。HttpContext.Current.Response.Write not working on 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上,我成功地調試它,這是不言而喻的代碼,但是,最終的結果我沒有看到劇本,我嘗試了不同的腳本,仍然沒有運氣

回答

0

我知道我的答案是這麼晚了,但也許會有所幫助! 你可以試試:

obj.removeAttribute('dsplay');