• <legend id='fKnpA'><style id='fKnpA'><dir id='fKnpA'><q id='fKnpA'></q></dir></style></legend>
    <i id='fKnpA'><tr id='fKnpA'><dt id='fKnpA'><q id='fKnpA'><span id='fKnpA'><b id='fKnpA'><form id='fKnpA'><ins id='fKnpA'></ins><ul id='fKnpA'></ul><sub id='fKnpA'></sub></form><legend id='fKnpA'></legend><bdo id='fKnpA'><pre id='fKnpA'><center id='fKnpA'></center></pre></bdo></b><th id='fKnpA'></th></span></q></dt></tr></i><div id='fKnpA'><tfoot id='fKnpA'></tfoot><dl id='fKnpA'><fieldset id='fKnpA'></fieldset></dl></div>

      <bdo id='fKnpA'></bdo><ul id='fKnpA'></ul>

    <small id='fKnpA'></small><noframes id='fKnpA'>

      <tfoot id='fKnpA'></tfoot>
      1. 使用JQuery打开一个弹出窗口并打印

        时间:2023-10-01
            <i id='A3f9T'><tr id='A3f9T'><dt id='A3f9T'><q id='A3f9T'><span id='A3f9T'><b id='A3f9T'><form id='A3f9T'><ins id='A3f9T'></ins><ul id='A3f9T'></ul><sub id='A3f9T'></sub></form><legend id='A3f9T'></legend><bdo id='A3f9T'><pre id='A3f9T'><center id='A3f9T'></center></pre></bdo></b><th id='A3f9T'></th></span></q></dt></tr></i><div id='A3f9T'><tfoot id='A3f9T'></tfoot><dl id='A3f9T'><fieldset id='A3f9T'></fieldset></dl></div>

              <tbody id='A3f9T'></tbody>
            <tfoot id='A3f9T'></tfoot>
            • <bdo id='A3f9T'></bdo><ul id='A3f9T'></ul>

                  <legend id='A3f9T'><style id='A3f9T'><dir id='A3f9T'><q id='A3f9T'></q></dir></style></legend>
                1. <small id='A3f9T'></small><noframes id='A3f9T'>

                  本文介绍了使用JQuery打开一个弹出窗口并打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  不久前,我使用 jQuery 创建了一个灯箱插件,它将链接中指定的 url 加载到灯箱中.代码很简单:

                  A while back I created a lightbox plugin using jQuery that would load a url specified in a link into a lightbox. The code is really simple:

                  $('.readmore').each(function(i){
                      $(this).popup();
                  });
                  

                  链接看起来像这样:

                  <a class='readmore' href='view-details.php?Id=11'>TJ Kirchner</a>
                  

                  该插件还可以接受宽度、高度、不同 url 和更多要传递的数据的参数.

                  The plugin could also accept arguments for width, height, a different url, and more data to pass through.

                  我现在面临的问题是打印灯箱.我进行了设置,使灯箱顶部有一个打印按钮.该链接将打开一个新窗口并打印该窗口.这一切都由灯箱插件控制.这段代码是这样的:

                  The problem I'm facing right now is printing the lightbox. I set it up so that the lightbox has a print button at the top of the box. That link would open up a new window and print that window. This is all being controlled by the lightbox plugin. Here's what that code looks like:

                  $('.printBtn').bind('click',function() {
                      var url = options.url + ( ( options.url.indexOf('?') < 0 && options.data != "" ) ? '?' : '&' ) + options.data;
                      var thePopup = window.open( url, "Member Listing", "menubar=0,location=0,height=700,width=700" );
                      thePopup.print();
                  });
                  

                  问题是脚本似乎没有等到窗口加载.它想在窗口出现的那一刻打印.结果,如果我在打印对话框中单击取消",它将一次又一次地弹出,直到窗口加载为止.第一次尝试打印时,我得到了一个空白页.那可能是因为窗口没有完成加载.

                  The problem is the script doesn't seem to be waiting until the window loads. It wants to print the moment the window appears. As a result, if I click "cancel" to the print dialog box, it'll popup again and again until the window loads. The first time I tried printing I got a blank page. That might be because the window didn't finish load.

                  我需要找到一种方法来更改先前的代码块,以等待窗口加载然后打印.我觉得应该有一个简单的方法来做到这一点,但我还没有找到它.要么这样,要么我需要找到一种更好的方法来打开弹出窗口并从父窗口中的灯箱脚本打印,而无需在弹出窗口中交替网页代码.

                  I need to find a way to alter the previous code block to wait until the window loads and then print. I feel like there should be an easy way to do this, but I haven't found it yet. Either that, or I need to find a better way to open a popup window and print from the lightbox script in the parent window, without alternating the webpage code in the popup window.

                  推荐答案

                  你应该把 print 函数放在你的 view-details.php 文件中,并在文件加载后调用它,或者使用

                  You should put the print function in your view-details.php file and call it once the file is loaded, by either using

                  <body onload="window.print()"> 
                  

                  $(document).ready(function () { 
                    window.print(); 
                  });
                  

                  这篇关于使用JQuery打开一个弹出窗口并打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:每次设置弹出窗口的焦点 下一篇:如何个性化警报按钮 - window.confirm() 和 window.alert()

                  相关文章

                  <legend id='YfUqg'><style id='YfUqg'><dir id='YfUqg'><q id='YfUqg'></q></dir></style></legend>

                  <small id='YfUqg'></small><noframes id='YfUqg'>

                    <bdo id='YfUqg'></bdo><ul id='YfUqg'></ul>

                  1. <i id='YfUqg'><tr id='YfUqg'><dt id='YfUqg'><q id='YfUqg'><span id='YfUqg'><b id='YfUqg'><form id='YfUqg'><ins id='YfUqg'></ins><ul id='YfUqg'></ul><sub id='YfUqg'></sub></form><legend id='YfUqg'></legend><bdo id='YfUqg'><pre id='YfUqg'><center id='YfUqg'></center></pre></bdo></b><th id='YfUqg'></th></span></q></dt></tr></i><div id='YfUqg'><tfoot id='YfUqg'></tfoot><dl id='YfUqg'><fieldset id='YfUqg'></fieldset></dl></div>
                    <tfoot id='YfUqg'></tfoot>