window.open在IE9上不起作用

时间:2013-11-20 11:48:24

标签: javascript internet-explorer-9

在Firefox,Chrome和IE10上它可以工作......但是在IE9上点击“Imprimer”时没有任何反应

<input type="submit" class="btn btn-primary" value="Imprimer" id="print_btn"
onclick="javascript:imprime_zone('Quiz', 'my_print')" >                          

这是JS:

<script >
function imprime_zone(titre, obj)
{

// Définie la zone à imprimer
var zi = document.getElementById(obj).innerHTML;

// Ouvre une nouvelle fenêtre
var f = window.open("", "QuizImpression", "height=780, width=1024,toolbar=0, menubar=0,               scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");

// Définit le style de la page
f.document.body.style.color = '#000000';
f.document.body.style.backgroundColor = '#FFFFFF';
f.document.body.style.padding = "10px";

// Ajoute les Données
f.document.title = titre;
f.document.body.innerHTML += " " + zi + " ";

// Imprime et ferme la fenêtre
f.window.print();
f.window.close();
return true;
}
</script>

1 个答案:

答案 0 :(得分:-1)

尝试在 window.open 下使用以下脚本,这也适用于ie9:

<script language="JavaScript">

    function openURL(winName, winURL) {
        var w = 1080;
        var h = 830;
        var t = Math.round((screen.height / 2) - (h / 2));
        var l = Math.round((screen.width / 2) - (w / 2));
        var props = "channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=yes,";
        props += "scrollbars=yes,status=no,titlebar=no,toolbar=no,";
        props += "top=" + t + ",left=" + l + ",height=" + h + ",width=" + w;

        win = window.open("", winName, props, false);
        win.location.href = winURL;
    }
</script>