Solved

Telling the Browser to print landscape via Jscript

Posted on 2000-05-11
5
353 Views
Last Modified: 2012-05-04
Is there a way to tell the browser to print landscape via a Jscript function?
If so can I see some sample code.

 Thanks.
0
Comment
Question by:7of9121098
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:bark10
ID: 2804434
The best you can do is have a Jscript call a print which pops up the usual print dialog box.  From there, you should be able to set the orientation.
0
 

Author Comment

by:7of9121098
ID: 2804607
Bark10 do you happen to have any sample code? Thanks....
0
 
LVL 3

Accepted Solution

by:
bark10 earned 50 total points
ID: 2804626
Call this function from whereever you want, ie. an image, a button, whatever.  [Usually using onClick("runPrint")]

<script>
function runPrint()
        {
        if (navigator.appName.indexOf('Microsoft') !=-1) parent.body.VBPrint()
        else if (window.print) parent.body.print();
        }
</script>


and just after the body tag place this...


   <object id=WBControl width=0 height=0
        classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>
        <SCRIPT LANGUAGE=VBScript><!-- //
        Sub VBPrint() On Error Resume Next
        WBControl.ExecWB 6,1
        End Sub
        // --></SCRIPT>

Then whenever you click your item, it will bring up the print dialog.

Hope this helps.

Bark10
0
 
LVL 3

Expert Comment

by:bark10
ID: 2804633
Oops, the call is supposed to be, onClick("runPrint()").
0
 

Author Comment

by:7of9121098
ID: 2804641
Thanks...
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

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

862 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

23 Experts available now in Live!

Get 1:1 Help Now