Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JavaScript to set the Internet Explorer browser's "Page Setup" properties

Posted on 2004-10-03
8
Medium Priority
?
744 Views
Last Modified: 2008-01-09
Hello,

I'm looking for a way in JavaScript to be able to set the browsers "Page Setup" properties. I'm specifically talking about IE 6+.  I would like to be able to set the page orientation and margins.  This is needed for printing purposes and not for displaying the page in the browser.  I have a wide table that  I need to print in landscape and adjust the browsers margins to fit this table on the paper. I will be opening a new window for printing this table.  I would like to set these properties myself and not have the user fiddle with them. Is this possible? Any other suggestions if not?

Thanks for any help,
0
Comment
Question by:nmachin
[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
  • 4
  • 4
8 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 12211107
Hi nmachin,

I don't know about margins. Try setting negative margins for you body tag with CSS:

<style type="text/css">

body {margin:-10px -10px;}

</style>

and see if that helps. As to printing landscape, it's not as clear with CSS. See here: http://home.tampabay.rr.com/bmerkey/examples/landscape-test.html

Regards,
Zyloch
0
 

Author Comment

by:nmachin
ID: 12211195
Zyloch,

It looks like I'll be able to make the negative margins work for the margin issue.

When I try a simple test html doc as listed below, it doesn't change it to landscape when I attempt to print it through IE.  The page appears in portraite with the right side of the table cut off.

Thanks,
nmachin


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test</title>

<style type="text/css" media="print">
div.page      {
writing-mode: tb-rl;
height: 80%;
margin: 10% 0%;
}
</style>

</head>
<body>
<div class="page">
<table border="1" width="900">
      <tr>
            <td>test</td>
      </tr>
</table>
</div>
</body>
</html>
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12211204
Yeah, data tables don't seem to work. You can try this (which only works for IE6):

div.page table {
margin-right: 80pt;
filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=1);
}
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.

 

Author Comment

by:nmachin
ID: 12211246
Zyloch,

I think we're getting close but get some pretty wild results using multiple tables.

<div class="page">
<table border="1" width="900">
     <tr>
          <td>
                <table border="1">
                     <tr>
                           <td>test</td>
                     </tr>
                  </table>
           </td>
     </tr>
     <tr>
          <td>test</td>
     </tr>
</table>
<table border="1" width="900">
     <tr>
          <td>test</td>
     </tr>
</table>
</div>

thanks,
nmachin
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12212390
That's odd. What do you get with multiple tables? Sorry I don't have a printer available *looks sheepish*
0
 

Author Comment

by:nmachin
ID: 12212416
When I nest the tables as listed,  the contents of table2 appear upside down .... gets rotated twice.

<table border="1" width="900" id="table1" >
     <tr>
          <td>
                <table border="1" id="table2" >
                     <tr>
                           <td>test</td>
                     </tr>
                  </table>
           </td>
     </tr>
</table>

When I put 2 tables side by side, each table is on a different page.

<table border="1" width="900">
     <tr>
                <td>test</td>
     </tr>
</table>
<table border="1" width="900">
     <tr>
                <td>test</td>
     </tr>
</table>
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 2000 total points
ID: 12212531
Hmm... This is a bit troublesome. It seems filter applies to everything, even the tables inside it. One possible way is to use two tables, but the second one has relative positioning? A bit "hackish" but I guess it should work.

I'm not too sure about the two tables side by side yet, so I'll let you know
0
 

Author Comment

by:nmachin
ID: 12215247
It looks like I got it!!  I used 1 table and DIV tags to define the nested tables.  Thanks for your help.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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 task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

688 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