【问题标题】:JQuery is not working in IEJQuery 在 IE 中不起作用
【发布时间】:2014-12-15 13:24:32
【问题描述】:

我的 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>

这里 id DZLabel.xml:

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

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

【问题讨论】:

  • Ajax 请求不适用于通过文件系统(而不是通过 http)打开的 本地 文件
  • 它可以在 chrome/others 中使用吗?
  • 双击Test.html,Internet Explorer地址栏出现什么地址?
  • 在点击处理程序内部有一个ready 回调没有任何意义(至少,不是针对同一页面)。
  • jQuery 1.4.3 已经 4 岁了。尝试使用当前版本。

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


【解决方案1】:

用途:

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

不是innerHtml。

这对我有用。

【讨论】:

  • 它永远不会进入这一行 alert("Cliked1");当我在 IE 中打开 Test.html 时(通过双击它)
  • 完全一样,您发布的内容。也许尝试像其他人提到的那样更新您的 jquery。
【解决方案2】:

使用jquery code 喜欢,

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

【讨论】:

    猜你喜欢
    • 2012-10-07
    • 2011-02-13
    • 2012-09-21
    • 2011-09-01
    • 2012-09-09
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多