ブラウザからの印刷を選択した後、レンダリングされたテンプレートページで実行する次のコードがあります。
<script type="text/javascript">
$(function() {
$("td:contains('Labour')").next("td").addClass("white");
var thisTr = $("td:contains('Labour')").parent();
thisTr.children().eq(2).addClass("white");
thisTr.children().eq(3).addClass("white");
});
</script>
CSS:
@media print {
body { margin:auto; }
.section { page-break-inside:avoid; }
div#sfWebDebug { display:none; }
.white {color: white;}
}
コードを確認したところ、通常のブラウザウィンドウで機能しています:http://jsfiddle.net/elen/vArH8/
しかし、white
クラスは印刷するポップアップには適用されないようです。ChromeとFirefoxで試してみました。
ブラウザは印刷時にJavaScriptの実行を許可しますか?
私自身のばかげた質問に答える-最初にjqueryプラグインをテンプレートに追加すると役に立ちます!
次のコードは完全に機能します。
<script type="text/javascript">
$(document).ready(function() {
var thisTr = $("td:contains('Labour')").parent();
thisTr.children().eq(1).empty();
thisTr.children().eq(2).empty();
thisTr.children().eq(3).empty();
window.print();
});
</script>