JQuery不在IE中工作

时间:2014-12-15 13:24:33

标签: jquery internet-explorer internet-explorer-11

我的html中有以下代码,当我从visual studio打开该文件作为网站时它工作正常。但是,当我双击Test.html并在IE中打开它时,它不起作用。

<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="chrome=1" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Print Me That Label</title>
        <script src="jquery-1.4.3.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            function clickMe()
            {
                alert("Clicked");
                var labelXml = "test";
                $(document).ready(function() {
                    $.get("DZLabel.xml", function (labelXml) {
                        alert("Clicked1");
                        document.getElementById("labelTextArea").innerText = labelXml;
                    }, "text");
                });
            }
        </script>
    </head>
    <body>
        <label for="labelTextArea">Text on the label:</label>
        <textarea name="labelTextArea" id="labelTextArea" rows='2'></textarea>
        <button id='printButton' onclick="clickMe()">CLICK</button>
    </body>
</html>

此处为DZLabel.xml

<?xml version="1.0" encoding="utf-8" ?>
<DieCutLabel Version="8.0" Units="twips">
  <PaperOrientation>Landscape</PaperOrientation>
  <Id>Address</Id>
 </DieCutLabel>

我的IE设置有什么问题吗?

2 个答案:

答案 0 :(得分:0)

使用:

document.getElementById("labelTextArea").value = labelXml;

不是innerHtml。

这对我有用。

答案 1 :(得分:0)

使用jquery code之类的

$(function(){  
    $('#printButton').bind('click',function(){
        $.get("DZLabel.xml", function (labelXml) {
            alert("Cliked1");
            $("#labelTextArea").val(labelXml);
        }, "text");
    });    
});