Solved

Set the Printer Page Property through Javascript

Posted on 2004-09-30
9
586 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

708 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

16 Experts available now in Live!

Get 1:1 Help Now