How to I redirect to another page *after* printing document?

前端 未结 5 1613
悲&欢浪女
悲&欢浪女 2020-12-17 06:31

I have an event called SubmitResponse().

A user is presented with a list of questions and possible responses. After completing the responses, the user

相关标签:
5条回答
  • 2020-12-17 07:06

    For cross browser compatibility, you need to introduce a delay between the window.print() call and the redirect.

    I find the following works well (using JQuery framework to print a page as soon as it loaded):

     <script type="text/javascript">
        $(document).ready(function () {
            window.print();
            setTimeout("closePrintView()", 3000);
        });
        function closePrintView() {
            document.location.href = 'somewhere.html';
        }
    </script>
    

    This can be easily adapted for "Print" buttons and links etc.

    0 讨论(0)
  • 2020-12-17 07:22

    You can do the printing and redirect all via javascript. Here is an example that should work:

    function doPrint() {
        window.print();            
        document.location.href = "Somewhere.aspx"; 
    }
    

    Link it to a Button:

    <asp:Button ID="btnPrint" runat="server" Text="Print"
        OnClientClick="doPrint(); return false;" />
    
    0 讨论(0)
  • 2020-12-17 07:26

    Redirect on client side using javascript/jQuery

      onclick="window.print();window.location.href='results.aspx';"
    

    For your case

     insub.Attributes.Add("OnClick", "print_form();window.location.href='results.aspx';")
    
    0 讨论(0)
  • 2020-12-17 07:29

    you can use this code :

    window.print();
    window.onafterprint = function(event) {
        window.location.href = 'index.php'
    };
    

    using window.print() callBack!!

    0 讨论(0)
  • 2020-12-17 07:31
    <script type="text/javascript">window.location = 'url.aspx';</script>
    
    0 讨论(0)
提交回复
热议问题