日期:2014-05-16  浏览次数:20344 次

求大神帮忙
我本想做个想win7旗舰版桌面能自动换背景的网页,先是做了一个可是却出问题,求指导
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="Model.WebForm5" %>

<!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>
    <script type="text/javascript">    
    function change() {
        document.getElementById("bg").style.backgroundImage = "url(images/show_fengjingta_236621_4.jpg)";
    }
    setTimeout(change(), 1000)
    </script>
</head>

<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div id = "bg">
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
            </asp:Timer>
        </ContentTemplate>        
        </asp:UpdatePanel>
        
    </div>

    
    </form>
</body>
<div>
</div>
</html>

运行时却说无法找到style值 这是为什么

------解决方案--------------------

setTimeout(change, 1000); //去掉()后在FF和IE6都可以执行。