Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

I found that in Firefox 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), Firefox and Chrome.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
149 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.

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. 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.

  2. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...