1

新しいウィンドウを開いて、javascript と jquery-1.8.3 でフォーム データを送信しようとしています。

Bernhard の助けを借りて、印刷用のページを含む新しいウィンドウを呼び出すことに成功しました。

(Bernhard さん、ありがとうございます。window.open とフォーム データの送信が機能しません)

しかし、window.print()関数はIE9では動作しません! (FF、クロムはよくやる)

ページを更新すると、IE9 が呼び出されますwindow.print()

ここにソースコードがあります。

<a href="#" onclick="printPage()">Print this</a>

<script type="text/javascript" src="/common/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">

function printPage(){

    $.post('/common/print.jsp', {view:$("#ctn").html()}).success(function(response){
        var oWindow = window.open('', "printWindow", "width=700px,height=800px");
        oWindow.document.write(response);
        oWindow.print(); // I added this line. But IE9 not working.
    });
}
</script>

私が逃したものはありますか?

4

1 に答える 1

1

これを試してください:

    $.post('/common/print.jsp', {view:$("#ctn").html()}).success(function(response){
        var oWindow = window.open('', "printWindow", "width=700px,height=800px");
        oWindow.document.write(response);
        oWindow.document.close();
        oWindow.focus();
        oWindow.print(); // I added this line. But IE9 not working.
    });

これをチェックアウト:

Using HTTP Headers to Force Standards View in Internet Explorer 8 and Above

メタ タグを使用して標準モードを強制することもできます。はX-UA-Compatible meta tag、使用またはエミュレートする表示モードを Internet Explorer に指示します。

By setting this meta tag, you tell IE to use standards mode even if there are comments or an XML declaration above the DOCTYPE.determine what version of Internet Explorer can best view the page次に、メタ タグを設定してそのバージョンを定義します。

IE 7:

<meta http-equiv="X-UA-Compatible" value="IE=7"> 

IE 8:

<meta http-equiv="X-UA-Compatible" value="IE=8"> 

IE 9:

<meta http-equiv="X-UA-Compatible" value="IE=9"> 

顧客が、サポートされているよりも高い表示モードでページにアクセスした場合 (IE8 表示モードを要求するページを表示している IE 7 ブラウザーなど)、タグを無視し、タグがない場合のモードでページをレンダリングします。

詳細はこちら: http://webdesign.about.com/od/internetexplorer/qt/force-compatibility-view-in-ie.htm

于 2013-01-09T06:18:04.107 に答える