0

我有这个 JavaScript。在 jquery 移动。我希望它只显示在这个 div 中。现在当我运行它时,它不显示任何样式或 jquery。只显示javascript。

    <%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
        CodeFile="phonedirectory.aspx.vb" Inherits="phonedirectory" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <div class="timeline" id="lists" data-role="content">
                   </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div data-role="page">
        <div data-role="header" data-theme="c">
            <center>
                <a href="Default.aspx">
                    <img src="Content/images/logo.png" /></a></center>
        </div>
          <script language="javascript" type="text/javascript">
                        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                            xmlhttp = new XMLHttpRequest();
                        }
                        else {// code for IE6, IE5
                            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        xmlhttp.read
                        xmlhttp.open("GET", "xml.aspx", false);
                        xmlhttp.send();
                        xmlDoc = xmlhttp.responseXML;

                        document.write("<ul id='employee' data-role='listview' data-filter='true'>");
                        var x = xmlDoc.getElementsByTagName("employee");
                        for (i = 0; i < x.length; i++) {
                            document.write("<li class='ui-screen-hidden'>")
                            document.write("<a href='info.aspx?ID=");
                            document.write(x[i].getElementsByTagName("ID")[0].childNodes[0].nodeValue);
                            document.write("'>")
                            document.write(x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue);
                            document.write("</a></li>");
                        }
                        document.write("</ul>");


                </script>
                </div>

4

1 回答 1

0

Firstly, you don't close the script tag.

Secondly, if you're writing JavaScript in an HTML page, you should use single quotes to avoid clashing with the double quotes used for HTML markup, or escape your double quotes.

于 2012-11-12T13:23:29.757 回答