问题描述
我想在用户打印某个网页时将一些信息发回给我的数据库。我可以在IE中用 onbeforeprint()
和 onafterprint()
来做到这一点,但我想浏览器不可知的做法一样的东西。不必关心我必须使用哪些技术组合(PHP,MySQL,JavaScript,HTML),只要完成即可。任何想法?
编辑:
仍有一些问题。我试着把我的函数放在我的 Print.css
中作为一个图像,但是我搞砸了一些方法。然后我试着添加一个事件监听器,但我无法让它工作得很好。如果任何人都可以提供一些关于如何在任何浏览器打印之前调用函数的更多细节,我将不胜感激。
$ b 编辑:
现在我放弃了这个,我已经用另一种做我想做的方式来解决了。我期待着FireFox支持onbeforeprint()和onafterprint()的那一天。 https://bugzilla.mozilla.org/show_bug.cgi?id=307258rel =noreferrer>确保其他浏览器可以让你。您当然可以在打印样式表中的某处指定图片,这可能只会在打印时调用,用于 onbeforeprint
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?
EDIT:
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.
EDIT:
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().
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浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!