【问题标题】:Jquery id selector not working on INTERNET EXPLORERJquery id 选择器在 INTERNET EXPLORER 上不起作用
【发布时间】:2011-05-10 16:50:51
【问题描述】:

为什么这在 INTERNET EXPLORER 上不起作用:

我有这个 html 输入标签。我调用我的 js 函数在 toprint 元素上做一些工作。在 FF 中,chrome 可以正常工作。但是在 IE 上我得到“缺少参数错误”。

<input type="button" onclick="PrintElem('#ToPrint')" value="<?php echo t("DOWNLOAD");?>" />

div 元素位于页面中的某处,例如:

    <div class="letterBody paddingLg LmarginXlg"  id="ToPrint">
<p>bla bla</p>
</div>

 <script type="text/javascript" language="javascript">


    function PrintElem(elem)

    {

        Popup($(elem).html());
    }

    function Popup(data)

    {

        var mywindow = window.open('', 'Press Release');
        mywindow.document.write('<html><head><title><?php echo $data->title  ;?></title>');
        mywindow.document.write(' <link rel="stylesheet" type="text/css" media="all" href="<?php echo base_path().$directory; ?>/css/printA4.css"/>');
        mywindow.document.write('</head><body  onload="" class="printA4">');
        mywindow.document.write(data);

/*
                $(document).ready(function() {
                this.title = '<?php echo $data->title  ;?>'


                 var salonLogo =   $("#salonLogo").attr("src")
                 var imgSalonLogo = salonLogo.search("salonlogo")
                 if(imgSalonLogo == -1){
                     $("#salonLogo").attr("src","")
                 }


                })
*/

        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.print();
        return true;
    }

    $(document).ready(function() {
    this.title = '<?php echo $data->title  ;?>'
    })

</script>

【问题讨论】:

  • 请描述您的错误。 IE版??错误在哪一行没有。??格式正确
  • 但是 ie 会发生什么?没有弹窗?弹出的值错误?

标签: jquery internet-explorer


【解决方案1】:

错误大概在这一行:

var mywindow = window.open('', 'Press Release');

在 IE 中,窗口名称不能包含空格,因为它被映射到 window 变量。

使用类似的东西

var mywindow = window.open('', 'PressRelease');

请在未来始终显示错误发生的确切行和确切错误 - 我认为它抱怨的是 invalid 参数,而不是 missing一个。

【讨论】:

  • yUP?美妙的帕卡。好的建议
猜你喜欢
  • 2011-01-25
  • 2015-12-08
  • 2015-05-13
  • 2011-03-24
  • 2011-05-21
  • 1970-01-01
  • 2010-09-07
  • 2012-07-31
  • 2017-08-06
相关资源
最近更新 更多