Ash Burlaczenko
Ash Burlaczenko

Reputation: 25435

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.

Upvotes: 0

Views: 2388

Answers (2)

toby
toby

Reputation: 902

Some browsers have an option bypass the dialog, but it can't be done in javascript.

Upvotes: 0

SLaks
SLaks

Reputation: 887395

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.

Upvotes: 1

Related Questions