Link to home
Start Free TrialLog in
Avatar of nmachin
nmachin

asked on

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

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,
Avatar of Zyloch
Zyloch
Flag of United States of America image

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
Avatar of nmachin
nmachin

ASKER

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>
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);
}
Avatar of nmachin

ASKER

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
That's odd. What do you get with multiple tables? Sorry I don't have a printer available *looks sheepish*
Avatar of nmachin

ASKER

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>
ASKER CERTIFIED SOLUTION
Avatar of Zyloch
Zyloch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nmachin

ASKER

It looks like I got it!!  I used 1 table and DIV tags to define the nested tables.  Thanks for your help.