none
window.matchmedia not firing for 'Print' in IE RRS feed

  • Question

  •  

    Problem Statement:

    We are trying to resize our DOM element based on the print preferences selected by user on print preview using matchmedia. matchMedia is supported by IE but not triggering the callback events .

    Approach followed:

    I am listening the beforePrint callback for print but once ctrl + P is done, there are no callbacks on page preference changes on which I need to modify my DOM as per the page size. matchMedia is not working in this case.

    if ( window.matchMedia ) {

                    var mediaQueryList = window.matchMedia( 'print' );
                    mediaQueryList.addListener( function ( mql ) {
                        if ( mql.matches ) {
                            beforePrint();
                        } else {
                            afterPrint();
                        }
                    } );
                }


    Tuesday, July 12, 2016 11:02 AM

Answers