在打印上点击如何打开另一页

on print click how to open another page?

本文关键字:何打开 一页 打印      更新时间:2023-09-26

当我点击打印按钮时,我已经编写了以下函数来调用另一个页面。但是当我点击打印按钮时,它打开的是当前页面,而不是我想调用的那个。

function printme(tripId, requestId, Ecommerce) {
        //alert("print is called");
        alert(tripId);
        alert(requestId);
        alert(Ecommerce);
        window.location.href = "ViewTripConformationPrint.cshtml?";
        window.print();
        //workaround for Chrome bug - https://code.google.com/p/chromium/issues/detail?id=141633
        if (window.stop) {
            location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
            window.stop(); //immediately stop reloading
        }
        return false;
    }

您遇到的问题是,设置window.location.href后的代码立即执行。页面没有加载,然后代码继续…代码将继续执行,直到函数结束,然后实际加载并处理window.location.href。如果你明白我的意思。

你可以试着把你的代码移到窗口。打印,如果窗口。停止等)到viewtripconfigurationprint。CSHTML(作为onload的一部分).