How to change/remove "about:blank" at bottom of Print page

How to change/remove "about:blank" at bottom of Print page

GreybeardTheUnreadyGreybeardTheUnready Posts: 3Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • rf1234rf1234 Posts: 2,997Questions: 87Answers: 421

    Link to test case: ??

  • GreybeardTheUnreadyGreybeardTheUnready Posts: 3Questions: 1Answers: 0

    Thanks @rf1234 - You forced me to do a bit more digging and if you simply try the example provided on the datatables site here

    https://datatables.net/extensions/buttons/examples/print/simple.html

    You will see "about:blank" in the bottom left of each page if you are using Google Chrome Version 106.0.5249.119,
    but not on Opera Version:91.0.4516.65
    or Edge Version 106.0.1370.42

    and on Firefox Version 105.0.3 "about:blank" appears top right.

    So I guess that the actual print service of the browser it inserting it :-(

    I'd still like how to control it...

  • GreybeardTheUnreadyGreybeardTheUnready Posts: 3Questions: 1Answers: 0

    ...so the 'about:blank' in Chrome and Firefox footer/header is normally set to the URL of the page being printed (and can't be explicitly set), so I assume that the window that datatables opens doesn't have a URL of its own,

    Only solution seems to switch off chrome's print footer.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    So I guess that the actual print service of the browser it inserting it :-(

    Correct. That is the header / footer of the browser's printing action. There is no javascript way of controlling that. It is a "feature" of the browser.

    Allan

  • paintingsilencepaintingsilence Posts: 2Questions: 0Answers: 0

    Id like to point out that about:blank can indeed be removed in a regular print dialog via JS as usually printing of content happens via a new document created with open()

    = window.open(' ', ' ', 'width=' + '1024px' + ', height=' + '800px');

    whereas the first parameters specifies the URL. If no space in between then browser will see URL as "about:blank" and prints in bottom left corner (chrome). IF first param is a blank space then Chrome does not print "about:blank" but sees the URL as a blank space. Following this logic in datatables the print mechanism should be adjustable as to open in a new window as described above.

    Will dig a little deeper but not sure this can be achieved via customize().. probably needs some adjustments at code level of datatables.

  • paintingsilencepaintingsilence Posts: 2Questions: 0Answers: 0

    alright I've had a look and if you change the following code at the datatables print module then about:blank should be removed as per explanation above. please let me know if it works as I have only quickly tested it with latest Chrome:

    in

    /*!
    * Print button for Buttons and DataTables.
    * 2016 SpryMedia Ltd - datatables.net/license
    */

    find

    var win = window.open( '', '' );
    if (! win) {
    dt.buttons.info(
    dt.i18n( 'buttons.printErrorTitle', 'Unable to open print view' ),
    dt.i18n( 'buttons.printErrorMsg', 'Please allow popups in your browser for this site to be able to view the print view.' ),
    5000
    );

    return;
    }

    win.document.close();

    and change to

    const win = window.open(' ', ' ', 'width=' + '1024px' + ', height=' + '800px');
    win.document.open();
    if (! win) {
    dt.buttons.info(
    dt.i18n( 'buttons.printErrorTitle', 'Unable to open print view' ),
    dt.i18n( 'buttons.printErrorMsg', 'Please allow popups in your browser for this site to be able to view the print view.' ),
    5000
    );

    return;
    }
    setTimeout(function() {
    win.focus();
    win.print();
    win.document.close();
    win.close();
    }, 1000);

    hope this helps!

    edit: using quote instead of code as code citation would break on me in preview.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Nice one - thanks for posting back. Does it work without the width and height parameters? I.e. just provide a single space string as the target name?

    Allan

Sign In or Register to comment.