Solved

Set the Printer Page Property through Javascript

Posted on 2004-09-30
9
594 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 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 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