问题描述
当用户打印某个网页时,我想将一些信息发送回我的数据库.我可以在 IE 中使用 onbeforeprint()
和 onafterprint()
来做到这一点,但我想以浏览器不可知的方式做同样的事情.只要完成,我就不必在意我必须使用哪种技术组合(PHP、MySQL、JavaScript、HTML).有什么想法吗?
I want to send some info back to my database when a user prints a certain web page. I can do this in IE with onbeforeprint()
and onafterprint()
but I would like to browser agnostic way of doing the same thing. Don't care which combination of technologies I have to use (PHP, MySQL, JavaScript, HTML) so long as it gets done. Any ideas?
仍然有一些问题.我尝试将我的函数作为图像放在我的 Print.css
中,但我在某些方面弄乱了它.然后我尝试只添加一个事件侦听器,但我也无法让它正常工作.如果有人能提供更多关于我如何在任何浏览器中打印之前调用函数的详细信息,我将不胜感激.
Still having some problems with this. I tried the putting my function in my Print.css
as an image, but I am messing it up some how. Then I tried just adding a event listener, but I cannot get that to work quite right either. If anyone can provide some more details on how I might call a function right before print in ANY browser I would appreciate it.
我暂时放弃了这个,我已经用另一种方式来做我想做的事.期待 FireFox 支持 onbeforeprint() 和 onafterprint() 的那一天.
I am giving up on this for now, I have settled with another way of doing what I want. I look forward to the day when FireFox supports onbeforeprint() and onafterprint().
推荐答案
我不确定其他浏览器将允许您.您当然可以在打印样式表的某处指定一个图像,它可能只会在打印时被调用,用于 onbeforeprint
I m not sure other browsers will allow you to. You could of course specify an image somewhere in a print stylesheet, which probably only will be called on a print, for the onbeforeprint
这篇关于onbeforeprint() 和 onafterprint() 等价于非 IE 浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!