0

私のWebページから、印刷アイコンがあります。アイコンをクリックすると、ポップアップページ「Print_content.aspx」が開きます

クエリ文字列をポップアップ ページに渡します ?print = 親ページの URL と DIV の名前を親ページ "#subcontent" で取得し、div サブコンテンツ (親ページ) 内のコンテンツをポップアップ ページにある div サイトローダーに読み込みます.

これは、Mozilla と Chrome で完全に機能します。しかしIEではそうではありません

ポップアップページのJquery:

    var value = window.location.search;   
    $(document).ready(function () {
        $("#siteloader").load(value.replace("?print=", "") + " #subcontent");
    });  
</script>  

Print_content.aspx のマークアップ全体

    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>

    <link href="../print.css" rel="stylesheet" type="text/css" />
    <title></title>
</head>
<body> 
    <table>
        <tr>
            <td>
                <div id="logo">
                </div>
            </td>
        </tr>
        <tr>
            <td align="center">
                <a runat="server" id="img_Print" onclick="window.print()">
                    <img id="Img1" runat="server" src="/image/btn_print.gif" /></a>

            </td>
        </tr>
        <tr>
        <td align="left">
          <div id="siteloader">
                </div>
        </td>
        </tr>
    </table>


    <script type="text/javascript">

        var value = window.location.search;   
        $(document).ready(function () {
            $("#siteloader").load(value.replace("?print=", "") + " #subcontent");
        });  
    </script>  

   <div id="div-overlay" style="position: absolute; top:130px; height: 100%; width: 100%; z-index: 200;  opacity: 0.0;background-color:Gray;"> </div> 
</body>
</html> 
4

1 に答える 1

0

var value = window.location.href代わりに使うつもりだったの?

PARENT ページから POPUP ページにコンテンツを印刷する別の方法としては、次のようなものがあります。

$("a.doPrint").click(function(e) {
  e.preventDefault();
  var printSource = $("#myElementToPrint");
  var printWindow = window.open("", "printWindow", "width=700,height=400,location=no,menubar=yes,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no");
  if(!printWindow) alert("Please enable popups to access this feature.");
  else {
    printWindow.onload = function() {
      setTimeout(function() {
        if (printWindow.screenX === 0) {
          alert("Please enable popups to access this feature.");
        }
      }, 0);
    };
    printWindow.document.write('<html><head><title>Printing Page</title></head><body>' + printSource.html() + '</body></html>');
    printWindow.print();
  }
  return false;
});
于 2013-06-05T03:30:37.487 に答える