从JS设置打印首选项 [英] Set Printing Preferences from JS

查看:99
本文介绍了从JS设置打印首选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以...从我在谷歌上找到的,我找不到使用Javascript设置我的打印首选项的方法(阅读:边距,方向,页脚等)。

So... from what I can find on the Google, I can't find a way to use Javascript to set my printing preferences (read: margins, orientations, footer, etc).

我即将告诉我的老板他不想做什么。我想检查一下,你会不会让人们做这件事。请告诉我。

I am about to tell my boss that what he wants to do isn't possible. I wanted to check will you fine folks priors to doing this. Please let me know.

我发现在FF中你可以使用一些user_pref(key,val)设置来设置用户的偏好,但这对我90%以上的用户不起作用用户。我正在寻找能够覆盖IE(尽可能多),FF和Chrome的东西。

I found that in FF you can use some user_pref(key,val) settings to set up the user's preferences, but that doesn't work for over 90% of my users. I am looking for something that will cover the IE's (as many as possible), FF and Chrome.

感谢忍者的回复。

推荐答案

所以...经过一整天的观察,我想我找到了自己问题的答案。简而言之,答案是JS和/或CSS不允许您覆盖客户端浏览器的默认页面设置。

So... after all day of looking, I think that I found the answer to my own question. In short, the answer is that JS and/or CSS will not allow you to override the default page setup of the client's browser.

这是我试过的。如果您使用和空头创建一个简单的HTML文件,并且只包含文本Test的正文,您将能够看到我测试的内容。

Here is what I tried. If you create a simple HTML file with and empty head, and a body that only contains the text "Test", you will be able to see what I tested.


  1. 打印样式表无法解决您的问题。将主体上的边距设置为0px 0px 0px 0px与单击文件>页面设置并将所有边距设置为0不同。尽管Print Style Sheeters希望您相信它们,但它们是不同的。亲自试试吧。这就是打印样式表无法解决问题的原因。

  1. Print Style Sheets cannot solve your problem. Setting the margin on the body to 0px 0px 0px 0px is not the same thing as clicking File > Page Setup and setting all of your margins to 0. Despite what Print Style Sheeters would like you to believe, they are different. Try it for yourself. This is why Print Style Sheets do not solve your problem.

JS无法解决您的问题。如果您访问的每个页面都修改了本地JS属性,您能成像吗?允许每个页面访问本地打印设置将是一个安全漏洞,是不允许的。因此,JS无法解决您的问题。

JS cannot solve your problem. Can you image if every page that you visited modified your local JS properties? To allow each page to have access to your local print setups would be a security breach, and is not allowed. Because of this, JS cannot solve your problem.

我希望有人回复,让我知道我错了。否则......这很糟糕......而且它需要发生。我有很多老用户......让他们在页面设置中设置边距是一件痛苦的事。此外,客户不希望我们重构页面,以便他们不需要。我介于摇滚和硬地之间。

I would love to have someone respond here and let me know that I am wrong. Otherwise... this sucks... and it needs to happen. I have a ton of old users... and getting them to set the margins in their page setup is a pain. Also the customer don't want us to refactor the page so that they don't need to. I am in-between a rock and a hard spot.

这篇关于从JS设置打印首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆