0
<script type="text/javascript">
$(document).ready(function () {
    showHome();
}); 

function findTemplate() {
var selectedIndustry = $("#industrySelected option:selected").text();
var selectedTemplate =$("#templateCode").val();
$.ajax({
    type: "post",
    url: "/_layouts/TBSharePointProject/SharePointTestService.asmx/redirectUserToAppropriateTemplate",
    contentType: "application/x-www-form-urlencoded",
    dataType: "xml",
    data: { industry: selectedIndustry, templateCode: selectedTemplate, checkList: "" },
    success: function (result) {
        xmlStr = xmlToString(result);
        xml = removeFirstAndLastLine(xmlStr)
        myJsonObject = xml2json.parser(xml);
        //alert(myJsonObject.eccn[0].eccnno);

        $("#surveyScreen").empty();
        for(var i = 0; i <= myJsonObject.eccn.length; i++) {

            $("#surveyScreen").append("<p><input id='" + myJsonObject.eccn[i].guid + "' type='checkbox' checked ='checked'>" + myJsonObject.eccn[i].eccnno + ": " + myJsonObject.eccn[i].title + "</input></p>");

        }
        $("#surveyScreen").append("<br/><input type='button' id='goHome' value='Back'     onclick =\"javascript: showHome();\"/>");
    },
    error: function (result) {
        alert('error occured');
    },
    async: true
});


}
//Converst xmlString to String
function xmlToString(xmlObj) {
if (navigator.appName == "Netscape") {
    return (new XMLSerializer()).serializeToString(xmlObj);
}
if (navigator.appName == "Microsoft Internet Explorer") {
    return xmlObj.xml;
}
}

function removeFirstAndLastLine(xmlStr) {
// break the textblock into an array of lines
var lines = xmlStr.split('\n');
// remove one line, starting at the first position
lines.splice(0, 2);
// join the array back into a single string
var newtext = lines.join('\n');
//Removes the last line
if (newtext.lastIndexOf("\n") > 0) {
    return newtext.substring(0, newtext.lastIndexOf("\n"));
} else {
    return newtext;
}
}

function showHome() {

$("#surveyScreen").empty();
$("#surveyScreen").append("<p>Do you have a saved checklist?</p>");
$("#surveyScreen").append("<p>Submission Code:<input type='text' id='checkListCode'/>    </p>");
$("#surveyScreen").append("<p><input type='button' id='getCheckList' value='Get Saved     Checklist' onclick =\"javascript: findTemplate();\"/></p><br/><br/>");
$("#surveyScreen").append("<p>Industry</p>");
$("#surveyScreen").append("<select id='industrySelected'>"+
                            "<option>Computer & Networking</option>"+
                            "<option>Biotechnology</option>"+
                            "Industry</select>");
$("#surveyScreen").append("<br/>Or");
$("#surveyScreen").append("<p>Template Code:<input type='text' id='templateCode'/>    </p>");
$("#surveyScreen").append("<p><input type='button' id='getTemplate' value='Next'     onclick =\"javascript: findTemplate();\"/></p><br/><br/>");

}

</script>
<body>
<div id="surveyScreen">
</div>
</body>

この関数呼び出しがFirefoxでは機能するがIEでは機能しない理由と、IEで機能するために何をする必要があるのか​​を誰かに説明してもらえますか?

だから私は自分のコードをもっと表示するように投稿を更新しました..いくつかの部分が省略されています...そして他のいくつかは重要ではありません

4

2 に答える 2

3

重複するIDに関しては、IEの方がはるかに扱いにくいです。IDは(もちろん)一意である必要がありますが、Firefoxは最初のIDを取得して続行します。IEは、重複IDへのアクセスの試みを無視します。

あなたはあなたのHTMLを投稿しませんが、これは私が最初に見る方向です。

于 2013-02-22T16:19:29.807 に答える
0

このコード行が呼び出される前に、どこかにセミコロンがないことを確認してください。セミコロン(またはその他のエラー)が欠落していると、IEはエラーの場所で動作を停止しますが、FFでは引き続き動作することがわかりました。

コードはIE9で正常に機能しますhttp://jsfiddle.net/eL2nU/

$("#surveyScreen").append("<p><input type='button' id='getTemplate' value='Next' onclick=\"javascript: findTemplate();\"/></p><br/><br/>");
于 2013-02-22T16:25:44.653 に答える