1

我在 IE 中过早地触发了 jquery 就绪函数,但在 chorme 和 firefox 中没有

我有如下母版页

<%@ Master Language="C#" AutoEventWireup="true" Inherits="Site" EnableTheming="true"
    CodeBehind="Site.master.cs" %>

<%@ Register Src="Controls/WebStyle/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="Controls/WebStyle/Footer.ascx" TagName="Footer" TagPrefix="uc2" %>
<%@ Register Src="Controls/WebStyle/OuterFooter.ascx" TagName="OuterFooter" TagPrefix="uc3" %>
<!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>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body id="masterBody">
    <form id="form1" runat="server">
    <div id="container">
        <uc1:Header ID="Header1" runat="server" />
        <div style="padding: 10px;">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
        <uc2:Footer ID="Footer1" runat="server" />
    </div>
    <uc3:OuterFooter ID="OuterFooter1" runat="server" />
    </form>
</body>
</html>

在听者.ascx

<%@ Control Language="C#" AutoEventWireup="true" Inherits="Controls_Header" CodeBehind="Header.ascx.cs" %>
<div id="header">
    <div style="float: left;">
        <h1>
            Out Door Sport</h1>
    </div>
    <div style="float: left;">
        Shopping cart
    </div>
    <div style="clear: both;">
    </div>
    <div style="background-color: #fafafa; border: 1px solid #e5e5e5;">
        <div class="menu">
        </div>
        <div style="float: right; padding: 2px 10px 0 0;">
            <div style="float: left;">
                <input type="text" style="height: 24px; vertical-align: middle;" />
            </div>
            <div style="float: left;">
                <img src="Images/search.gif" />
            </div>
            <div style="clear: both;">
            </div>
        </div>
        <div style="clear: both;">
        </div>
    </div>
</div>

在 site.js 中

$(function () {
    alert($('body').html());
})

在 default.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="UD.Web.App.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="Scripts/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery.navigator.js" type="text/javascript"></script>
    <script src="site.js" type="text/javascript"></script> 
    <script src="Default.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
    <div class="treeview"></div>
    </div>
</asp:Content>

问题是表单标签结束并仅显示一些 asp.net 生成的东西。这发生了五分之一。警报代码如下

<form method="post" action="default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1Mg9kFgJmD2QWAgIDD2QWBAIBD2QWAgIDD2QWAmYPFgIeC18hSXRlbUNvdW50AgIWBGYPZBYCAgEPDxYGHghJbWFnZVVybAUSfi9JbWFnZXMvZW4tVVMuZ2lmHg1BbHRlcm5hdGVUZXh0BQdFbmdsaXNoHgdUb29sVGlwBQVlbi1VU2RkAgEPZBYCAgEPDxYGHwEFEn4vSW1hZ2VzL3N2LVNFLmdpZh8CBQdTd2VkaXNoHwMFBXN2LVNFZGQCCw8WAh4JaW5uZXJodG1sBQItMWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgIFQ2N0bDAwJE91dGVySGVhZGVyMSRTZWxlY3RDdWx0dXJlMSRkbENvdW50cmllcyRjdGwwMCRJbWFnZUJ1dHRvbkZsYWcFQ2N0bDAwJE91dGVySGVhZGVyMSRTZWxlY3RDdWx0dXJlMSRkbENvdW50cmllcyRjdGwwMSRJbWFnZUJ1dHRvbkZsYWfvfqd4cotpT4849hNOoTu9obRzdw==" />
</div>

<script type="text/javascript">
//<![CDATA[
    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
//]]>
</script>


<script src="/WebResource.axd?d=YZToayqm_u92yQAeP-tJgEnhMpuABJ6Lcu4NHJQLuf3BVbwarcvFeGzQ4reAcVYOL3vG8GSIy16UR3eAxCbDP8Rnsew1&amp;t=634678095121673705" type="text/javascript"></script></form>
4

0 回答 0