Forum Moderators: open
//test to see if their pop up blocker is on
var mine = window.open('','','width=1,height1,left=-10,top=-10,scrollbars=no');
if (mine) {
var popUpsBlocked = false
mine.close()
} //if mine
else {
var popUpsBlocked = true
}//else
if(popUpsBlocked){
alert("You are blocking pop ups from this site.\n"+
"In order to use the print function, you must allow popups.\n" +
"Please browse to SNIP"+
" if you are unsure how to do this.");
}//if popUpsBlocked
Thanks,
[edited by: Fotiman at 4:18 pm (utc) on Dec. 4, 2009]
[edit reason] No URLs please. See TOS [webmasterworld.com] [/edit]
That said, though, if this popup check is only needed to determine if the user can print, then why not simply move that code to only execute when the user tries to print? That is, instead of executing every time the page loads, only execute it when the user tries to print (I'm assuming you have some button or link that the user clicks on, so attach that code to the event handler for that button).
I'm not following how the setTimeout function would help me in this case.
The setTimeout is what's causing it to pop up once a second. If you want to just check it once, on site entry, you'll need to locate this and disable it.
How else do I accomplish that without creating a new page with printer friendly html?
in your php,
echo (isset($_GET['print-me']))?'print stylesheet':'regular stylsheet';
Or if it's static HTML, or really simple (only a few items to hide,) use @media print selectors, setting non printing items to display:none.
@media print {
form input { display:none; }
}