开发者

Jquery id selector not working on INTERNET EXPLORER

Why this does not work ON INTERNET EXPLORER:

I have this html input tag. I call my js function to do some staff on the toprint element. In FF, chrome it works. But on IE I get "missing argument error".

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

The div element is somewhere in the page like:

    <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() {
           开发者_JAVA百科     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>


The error is probably in this line:

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

in IE, the window name must not contain spaces, because it gets mapped to a window variable.

Use something like

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

Please in the future, always show the exact line the error is happening in, and the exact error - I think it complained about an invalid argument, not a missing one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜