Solved

Set the Printer Page Property through Javascript

Posted on 2004-09-30
9
589 Views
Last Modified: 2009-07-29
Hi,
  I'm using javascript to print the html page but at the end of the page i'm getting the page url.how to avoid this page url from print .

  i'm using window.print() function to print the page

Help me how to print only the content of the html page and avoid printing the page header and footer of the page.

 Pls send me some sample code that would help to solve this.

Thanx
 
0
Comment
Question by:mohan21_kumar
  • 3
  • 3
9 Comments
 
LVL 1

Accepted Solution

by:
sijgs earned 25 total points
ID: 12201826
I do it with Active X:

      var x;
      function SetPrintProperties()
         {
            x = new ActiveXObject("WScript.Shell");
            x.SendKeys("(%f)u");   // alt-f u=setup
            x.SendKeys("(%h)");    // header
            x.SendKeys("{BS}");    // None
            x.SendKeys("(%f)");    // Footer
            x.SendKeys("{BS}");   // None
            x.SendKeys("~");       // Enter O.K.
        }

Regards,
JGS
0
 
LVL 1

Author Comment

by:mohan21_kumar
ID: 12215625
hi,

 Thank u for ur reply

<script language="javascript">
      var x;
       function SetPrintProperties()
         {
               x = new ActiveXObject("WScript.Shell");
            x.SendKeys("(%f)u");   // alt-f u=setup
            x.SendKeys("(%h)");    // header
            x.SendKeys("{BS}");    // None
            x.SendKeys("(%f)");    // Footer
            x.SendKeys("{BS}");   // None
            x.SendKeys("~");       // Enter O.K.
          window.print();
/*             var oShell= new ActiveXObject("WScript.Shell");
              oShell.SendKeys( "%{PRTSC}" );
            window.print();*/

         }
</script>
<body onload="SetPrintProperties()">
<form>

      This is a test page for printing<br>
      This is a test page for printing<br>
      This is a test page for printing<br>
      This is a test page for printing<br>
      This is a test page for printing<br>
      This is a test page for printing<br>
      This is a test page for printing<br>
      This is a test page for printing
</form>
</body>

I have used the above code but still i'm getting the url
Pls help Me
0
 
LVL 1

Expert Comment

by:sijgs
ID: 12217894
MK:

After it prints, open the print properties window and see if the header and footer are actually set to nothing...  AFAIK the &u is the URL indicator and if it's gone from the footer I would have NO clue.

JGS
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:mohan21_kumar
ID: 12224028
Hi,

   In Page setup, the footer part contains "&u&b&d ". Can i change the footer part Programmatically
Pls Suggest me.
Thanx
0
 
LVL 1

Expert Comment

by:sijgs
ID: 12224260
MK:

Your security settings for Active-X are not "loose" enough to allow it to execute.

If you insert

alert("Begin Active-X");

before the .... new ActiveXObject...

and

alert("End Active-X");

before the window.print();

you will see what is not getting executed....

Go to Tools | Internet Options | Security | Trusted Sites | Custom

and set all IP's that you need and set all the Active-X entries in Custom to ENABLE

I don't know exactly which ones are the ones that allow it to work, but I know if you have the default settings, you get exactly what you see.... nothing... I just went through it last week..

Regards,
JGS
0
 
LVL 1

Author Comment

by:mohan21_kumar
ID: 12807098
I have found the solution for this question Pls delete the Question
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now