简体   繁体   中英

Javascript - How to disable the print dialog after first show?

On one of our pages the user has the option to print a selected list of html pages. This is how it is at the moment

var rowcount = FrmMain.RowCount;
var frame = FrmMain.Frame;
for(i=1;i<=rowcount;i++)
{
    var obj = FrmMain.elements("chk_" + i);
    if(obj.checked)
    {
        frame.src = FrmMain.elements("hpath" + i).value;
        window.frames[frame.id].focus();
        window.frames[frame.id].print();
    }
}

Now this works fine. The problem is that on each loop the print dialog box is displayed and the user has to click print.

Basically, what I'm asking is whether that is a way to supress this dialog. It must appear at the first time but hide thereafter. Some thing like below

var show = true;
...
{
    ...
    {
        ...
        if(show)
        {
            window.frames[frame.id].focus();
            window.frames[frame.id].print();
            show = false;
        }
        else
        {
            window.frames[frame.id].focus();
            window.frames[frame.id].printwithoutdialog();
        }
    }
}

I hope I've been clear. Thanks in advance.

For security / privacy reasons, this is impossible.
Otherwise, ads would automatically print their brochures.

Instead, you can combine all of the pages into a single frame.

某些浏览器提供绕过对话框的选项,但无法使用javascript完成。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM