?
Solved

Set the Printer Page Property through Javascript

Posted on 2004-09-30
9
Medium Priority
?
597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
9 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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 …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

719 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