It certainly sounds very neat. I just hope the browser support is good.
It certainly sounds very neat. I just hope the browser support is good.
Yes, it is a neat idea and it should work for you. As for browser support, whenever you're working with javascript (even styles), you'll need to really test things out. If you're willing to throw in some server-side scripting, you might want to "program" dynamic stylesheets instead of having a different one for each article (if I understood you correctly). For the sake of code-wise efficiency, a standard print-version page might be better, though.
Well, I've tried it but run into a bit of a problem. My code on the page head is
<script language="JavaScript">
<!--
var doAlerts=true;
function changeSheets(whichSheet){
whichSheet=whichSheet-1;
if(document.styleSheets){
var c = document.styleSheets.length;
if (doAlerts) alert('Change to Style '+(whichSheet+1));
for(var i=0;i<c;i++){
if(i!=whichSheet){
document.styleSheets[i].disabled=true;
}else{
document.styleSheets[i].disabled=false;
}
}
}
}
//-->
</script>
and the code for the style sheet change on the page is
However, the code is designed to switch normal style sheets, not print style sheets. If you try and do a switch, it substitutes one of the alternate print style sheets as a monitor-display style sheet
Is there any way of adjusting the javascript so it knows that the change only applies to print media style sheets?
Blessings and thanks
Tony
I can't get that script to work - it always chose the last print style sheet in the header.
However, I have found a different @import method, where the print style sheets are not in the header, and so cannot superimpose themselves when not wanted. It is descripted here:
http://www.notestips.com/80256B3A007F2692/...C1?OpenDocument
It works for me with a drop down list. All, I think, that I need to change, is
<select class="select2" onchange="var v=this.options[this.selectedIndex].value; if (v != '') selectStyle('style', v);">
into an onclick hyperlink on just an onclick word, eg something like
<span style="cursor:help;" onClick='var v=this.options[this.selectedIndex].value; if (v != '') selectStyle('style', v);'>Print</span>
(which doesn't display, cos I haven't got it right.
How can I make that link?
Thanks for your ideas!
Blessings
tony
PS sorry, what I should have said was, how can I combine
<select class="select2" style="width:165px" onchange="var v=this.options[this.selectedIndex].value; if (v != '') selectStyle('style', v);">
WITH
<option value="style-a">Style A</option>
into a single onclick action!
Blessings
Tony
PPS
I suspect on reflection it would be easier in PHP.
I have seen something similar described here:
http://forums.devshed.com/showthread.php?p...ed=1#post816969
What I'd want it to do is:
1. You click on a link or form button
2. That writes the URL of the new print style sheet onto the page, presumably after the page refreshes.
I assume that a form would do it.
Any thoughts?
Blessings and thanks
Tony
Hi folks
Is there any reason why they css swtiching technique here
http://www.codelifter.com/main/javascript/changestyles.html
could not be applied to what I need.
Which is:
a. A page has several news releases on it
b. I want to offer people the change to print just ONE of those news releases if they wish
c. To do this, a print-only css sheet would be activated for that particular news release, by clicking a button
d. Ideally, that button would also activate the browser print option at the same time.
e. Thus there would be several alternate print style sheets, each picking up only only a single news release.
Does that seem a practical thing? Is there a better way of doing it?
Blessings
Tony
Online outreach:
Internet Evangelism Day
Helping church websites:
Church Websites