Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Programmatically alter MSIE tools/internet option setting

 
joan frances fisher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! Another day another quandry...
Would anyone know if it is possible from Javascript to programmatically set the value of an Internet Explorer setting -- specifically..tools... /internet options... /advanced... /Printing /"Print background colors and Images" ?
I want to be able to disable the printing of the background color before the user opts to print the content of a screen...this will conserve toner and the time it takes to print....
Thank you!!!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
css has something for this and works with most browser 4+;
@media print {
.dontPrintMe{display : none;}
}
 
joan frances fisher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Al!! Just need a bit more clarification..
This is probably a naive question but Does the "none" in this code snippet indicate that the background color is not to be printed or equivalently set to white?
I do want the screen itself to be printed...just not the background color so as to conserve toner
Also...would you happen to know whether or not this programmatic setting will override the browser level setting that can be manually set from the tools/internet options/advanced tab/printing/"print background colors and images"?
Unfortunately I cannot ask the end user to go out to the browser and manually set this. I must accomplish everything programmatically.
I REALLY appreciate your help!!!
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking into all of this, i will try to post an answer in the next couuple of days. Dealing with Finite Element Analysis Homework and Robotics Homework and two tests within a week plus work. Going insane! (1 semester left then off to the real world)
 
joan frances fisher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hang in there, Al!! Believe it or not the real world will be relatively relaxing!! Best of luck well actually skill.. peppered with a teaspoon of luck!!)on your tests!
I patiently await your reply!
Thanx!
Joan
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay it is 1:30AM just got off of work and did some research for you. I did not test this, but I think this will work!
okay they way to do it is to have two style sheets for css.
Here is a good link on the basics of styles sheets if you do not know about them.
http://www.htmlhelp.com/reference/css/style-html.html
or
http://www.westciv.com/style_master/academy/css_tutorial/
okay now you do not have to go all out with it, you just need to include one thing for it, the background property,
here is how you link to the style sheet for printing:
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
<LINK REL=StyleSheet HREF="background.css" TYPE="text/css" MEDIA="screen">
That code goes in the header of the html document.
Now you will have two files print.css and background.css
now for the background.css you will need this code in it(Yes just one line unless you want to add other properties into it):
body {background-image: url("../images/TheBackground.gif"); }
now for the print.css, this is what i would do. Pick either solid white gif with a size 1x1 or a transparent gif of 1x1. Very small, takes microseconds to download. Save the same code as above, only changing the name:
body {background-image: url("../images/InVisibelBackground.gif"); }
I think that there might be a problem with N4.75 not recognizing the print, but I think you are only worrying about IE so you are in the clear
I am sure you know this, but if you do not know how to save a .css file, use notepad and save it as .css, that is the easiest way to do it withoutr any trouble.
Hope this does the trick.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for ie 5+
<BODY style="background-image:url(yourimage.jpg)"
onBeforePrint="document.body.style.backgroundImage=''"
onAfterPrint="document.body.style.backgroundImage='yourimage.jpg'">
 
joan frances fisher
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx so much for your solution, Ian..you RULE!!!
 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric, Can I ask you this?

How do I programmatically turn on the "printing background colors"? Images are getting printed even though browser setting is not enabled. God only knows.

I am breaking my head , but not working...

@media print {
.PrintMe{display : all;}
}

Its a very very important and urgent requirement for me.

Thanks in advance,
Shankar.S.Siddhaarth
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way you would be able to do it would be ActiveX with IE since it is a browser setting and nothing to do with CSS @media.

Eric
 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for quick reply Eric.

I will rephrase my question in this way. I use JSP to render the html. The user can have any setting, but my application should override the setting while printing. I am calling window.print() javascript inside rendered html. I require this to print background colors too irrespective of browser setting.

Best Regards,
Sankar
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp, asp,.net, php, perl, etc. does not have any control over anyone's browser. The only way for it to be done is to tell them to enable it or too find an activeX control that does it. (ActiveX might not even work, because they may have it blocked!)

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My solution is to generate a pdf for reports if it matters so much.

Eric
 
Sanjiv Jivan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking into all of this, i will try to post an answer in the next couuple of days. Dealing with Finite Element Analysis Homework and Robotics Homework and two tests within a week plus work.


Are you planning on a career switch to Mechanical Engineering? Most people I know have switched the other way round
 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Eric....

Even my customer also suggested the same solution.......PDF
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sanjiv Jivan:


Are you planning on a career switch to Mechanical Engineering? Most people I know have switched the other way round


This post was brought up from Sept. 2002 when I was still in college getting a degree in Mechanical Engineering from Penn State. I graduated that Dec. 2002. I am a .NET developer for a living.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic