i have page has number of divs content inside them. divs wrapped lines - 1 line in top , 1 in bottom sort of give user frame each div.
now have problem if divs have lot of content appearance in website , in actual printed page different. actual printed page needs more lines show same content, , need make div higher , lower bottom line.
i wrote code works in chrome:
var mediaquerylist = window.matchmedia('print'); mediaquerylist.addlistener(function (mql) { if (mql.matches) { changedivheight(); } });
for ff , ie code doesn't work. use:
window.onbeforeprint = function () { changedivheight(); }; window.onafterprint = function () { changedivheight(); } // need 2 because when i'm in web-site want height changed again because in print mode page thinner..
changedivheight looks @ div's child elements , adds heights div height. said works in chrome. in ff , ie doesn't work , think because don't have print preview, div doesn't change fit actual printed page, whereas in chrome have print preview div fits in actual printed page.
how can fix in ff , ie?
thanks!
edit
function changedivheight() { $.each(".div, function(index, div) { var newheight = 0; (i = 0; < div.children.length) { newheight += div.children[i].clientheight; } if (newheight > 240) { $(div.parent).css("height", newheight); } } }
and every div filled p elements may have lot of text
edit
i found because chrome has print preview, clientheight of paragraphs lot of text changes in print view, , works. in ie , ff don't have feature , height doesn't change, , doesn't work.
you should able without using jquery or javascript. if i'm understanding question correctly, can achieved using css, should compatible modern browsers. add following bottom of css.
@media print { #divtomakelarger { height: auto; /*or whatever value want*/ } }