bonaca bonaca - 8 months ago 39
Javascript Question

how to change font family for new window

I want to print the content of a div and have the following solution:; = 'Arial';

Everything works except
is not Arial but (I suppose) a default browser's serif font.


I guess you need an important property to set priority to your element

Try these answers

w.document.body.setAttribute('style', 'font-family:Arial !important');

else = 'font-family:Arial !important';

This below thing may not work in IE:"font-family", "Arial", "important");

Or you can append an inline styling

w.document.body.appendChild(document.createTextNode('td.EvenRow a {font-family:Arial !important;}'))

If nothing works have a class with style property as important and use body.addClass="xx".

Finally have your java script at the end of the HTML which seems to be the best solution than all the above manipulatons.