For browsers based on WebKit engine when print window opened the title of window has value "Untitled". Fix it for safari you can swap this code:
Code:
var win=window.open('','printgrid');
on this:
Code:
var win=window.open('about:blank','printgrid');
For Chrome this solution fixes problem not fully