why won't background change in firefox but it will in ie
Posted
by
rod
on Stack Overflow
See other posts from Stack Overflow
or by rod
Published on 2012-06-28T03:10:04Z
Indexed on
2012/06/28
3:15 UTC
Read the original article
Hit count: 112
JavaScript
|ASP.NET
<%@ 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>
Here's the ashx ProcessRequest
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
{
}
}
© Stack Overflow or respective owner