2012-06-28 44 views
0
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <link id="csslink" href="Handler.ashx" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <input id="Button1" type="button" value="Blue" /> 
     <input id="Button2" type="button" value="Red" /> 
    </div> 
    </form> 
    <script type="text/javascript"> 
     var pageDefault = { 
      btn1: document.getElementById('Button1'), 
      btn2: document.getElementById('Button2'), 
      csslink: document.getElementById('csslink'), 
      init: function() { 
       this.btn1.onclick = function() { 
        pageDefault.csslink.href = "Handler.ashx?id=1"; 
       } 
       this.btn2.onclick = function() { 
        pageDefault.csslink.href = "Handler.ashx?id=2"; 
       } 
      } 
     } 
     pageDefault.init(); 
    </script> 
</body> 
</html> 

,这里将是该ASHX的ProcessRequest为什么在Firefox不会背景的变化,但它在IE

public void ProcessRequest(HttpContext context) 
    { 
     context.Response.ContentType = "text/plain"; 
     var id = context.Request.QueryString["id"]; 

     if (id == "1") 
     { 

      context.Response.Write(@" 
body 
{ 
    background: Blue; 
} 

"); 
     } 
     else if (id == "2") 
     { 
      context.Response.Write(@" 
body 
{ 
    background: Red; 
} 

"); 
     } 
     else 
     { 

     } 
    } 

回答

1
context.Response.ContentType = "text/css"; 
+0

谢谢你的眼睛!感谢所有的反馈 – Rod

0

尝试使用:

body 
{ 
    /* Red */ 
    background-color: #ff0000; 
} 

body 
{ 
    /* Blue */ 
    background-color: #0c00ff; 
} 
+0

我改变了属性背景颜色但仍然没有运气以及六角形颜色 – Rod

+0

这适用于我在Firefox中,所以它可能是一个代码问题?你能显示你的代码生成的源代码吗? http://jsfiddle.net/REXZM/ – IrishChieftain

+0

酋长 - http://pastebin.com/buuGQVCb – Rod

相关问题