Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Set the Printer Page Property through Javascript

Posted on 2004-09-30
9
Medium Priority
?
598 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
6 Comments
 
LVL 1

Accepted Solution

by:
sijgs earned 100 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

876 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