mootools_使用CSS和MooTools修复sIFR打印

mootools

While I'm not a huge sIFR advocate I can understand its allure. A customer recently asked us to implement sIFR on their website but I ran into a problem: the sIFR headings wouldn't print because they were Flash objects. Here's how to fix the sIFR printing issue.

虽然我不是sIFR的拥护者,但我可以理解它的魅力。 一位客户最近要求我们在其网站上实施sIFR,但我遇到了一个问题:sIFR标题无法打印,因为它们是Flash对象。 这是解决sIFR打印问题的方法。

样本XHTML (Sample XHTML)


<h2>Sample Heading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut lectus fermentum augue bibendum tincidunt. In hac habitasse platea dictumst. Nullam ornare nunc ac massa. Nam volutpat tempor tortor. Maecenas sapien. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum a odio ut libero facilisis tincidunt.</p>

<h2>Sample Heading 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut lectus fermentum augue bibendum tincidunt. In hac habitasse platea dictumst. Nullam ornare nunc ac massa. Nam volutpat tempor tortor. Maecenas sapien. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum a odio ut libero facilisis tincidunt.</p>


Just some sample XHTML.

只是一些示例XHTML。

CSS (The CSS)


@media screen {
	.print-only	{ display:none; }
}
@media print {
	.print-only { display:block; }
	.no-print	{ display:none; }
}


Setting a couple of standard print-related CSS styles.

设置一些与打印有关的标准CSS样式。

MooTools JavaScript (The MooTools JavaScript)


$$('h2').each(function(el,i) {
		//new print-only h2
		 new Element('h2',{
			  text: el.get('text')
		 }).addClass('print-only').inject(el,'before');
		 
		//inject swiff into current h2
		el.addClass('no-print');
		var swiff = new Swiff('sifr450x23.swf',{
			 id: 'sifr-' + i,
			 width: 450,
			 height: 23,
			 container: el,
			 params: {
				  wMode: 'transparent'
			 },
			 vars: {
				  titleText:el.get('text')
			 }
		});
  });
});


We first inject a new H2 element that will be used for print. Then we inject the Swiff into the original H2. Of course you can see where I've added the print-only/no-print CSS classes.

我们首先注入一个新的H2元素,该元素将用于打印。 然后,将Swiff注入原始H2中。 当然,您可以看到我在哪里添加了仅打印/不打印CSS类。

The only browser I found that printed the Flash sIFR objects was Internet Explorer. This solution will work across all browsers.

我发现唯一打印Flash sIFR对象的浏览器是Internet Explorer。 该解决方案可在所有浏览器上使用。

翻译自: https://davidwalsh.name/sifr-print-css-mootools

mootools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值