D
DoomedLung
Hey everyone,
I'm writing a script that opens the current page into a new window
with a different style sheet for printing, don't ask me why it needs
to open into a new window, it's a request from powers that be! Anyway
when I reload the page in IE it's fine but in FF it seems to render
the html without a style sheet!!?? I think it may be to do a caching
problem in FF with new windows but I'm not sure. Heres the code I've
written:
var w, d, copy;
//
function printPage()
{
document.getElementById('pageTitle').innerHTML = document.title;
w = window.open('', '' ,'');
d = w.document;
copy = "<html>\n<head>\n<title>"+document.title+"</title>\n";
copy += "<link id='globalStyleSheet' type='text/css' rel='stylesheet'
href='css/globalPrint.css' />\n";
copy += "<link id='docStyleSheet' type='text/css' rel='stylesheet'
href='"+document.getElementById('docStyleSheet').href+"' />";
copy += "<script language='javascript' type='text/javascript'
src='scripts/js/utils.js'></script>\n";
copy += "\n</head>";
copy += "\n<body>";
copy += document.body.innerHTML;
copy += "\n</body>\n</html>";
d.write(copy);
d.close();
}
function init()
{
document.getElementById('printLink').onclick = function(){
printPage();
return false;
}
}
I've been racking my brain for a few days now and have finally come to
a brick for a work around..
Any help or your thoughts would be much appreciated
Cheers
I'm writing a script that opens the current page into a new window
with a different style sheet for printing, don't ask me why it needs
to open into a new window, it's a request from powers that be! Anyway
when I reload the page in IE it's fine but in FF it seems to render
the html without a style sheet!!?? I think it may be to do a caching
problem in FF with new windows but I'm not sure. Heres the code I've
written:
var w, d, copy;
//
function printPage()
{
document.getElementById('pageTitle').innerHTML = document.title;
w = window.open('', '' ,'');
d = w.document;
copy = "<html>\n<head>\n<title>"+document.title+"</title>\n";
copy += "<link id='globalStyleSheet' type='text/css' rel='stylesheet'
href='css/globalPrint.css' />\n";
copy += "<link id='docStyleSheet' type='text/css' rel='stylesheet'
href='"+document.getElementById('docStyleSheet').href+"' />";
copy += "<script language='javascript' type='text/javascript'
src='scripts/js/utils.js'></script>\n";
copy += "\n</head>";
copy += "\n<body>";
copy += document.body.innerHTML;
copy += "\n</body>\n</html>";
d.write(copy);
d.close();
}
function init()
{
document.getElementById('printLink').onclick = function(){
printPage();
return false;
}
}
I've been racking my brain for a few days now and have finally come to
a brick for a work around..
Any help or your thoughts would be much appreciated
Cheers