我想打开一个页面,但不要查看它,它会要求用户打印。打印URL的链接
这非常类似于Content Disposition
HTTP标头的功能。
设置为attachment
时,它会询问用户保存文件的位置(而不是在浏览器中显示)。
我打开页面的用户,所以我能use javascript的特权:
var doc = open(url); //open the link for them instead of using an anchor href
doc.print(); //ask them to print it, this is a blocking call until the user is done
doc.close(); //immediately close the window so the user isn't interrupted
但我真的很希望有一些服务器端的标志,我可以利用,是有这样的事?
打开的页面不一定是HTML文档,因此在其内部使用window.print();window.close();
在所有情况下都不起作用。
可能的重复[我们可以使打印按钮没有JavaScript?](http://stackoverflow.com/questions/1720013/can-we-make-print-button-without-javascript) –
HTTP不是HTML,但是看起来好像你的回答显示HTTP没有好的东西, – Hashbrown
也是,我想这个问题是指打印它当前所在的页面。不链接到其中将出现打印对话的文档*。 – Hashbrown