spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column95


Print Templates, Part VI: Interactive Margin Settings

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


The Margin Dashed Line

An important part of the margin manipulations is the dashed line that shows across the page where the margin is. The function ShowHideMargins() switches between showing and hiding the margins. We show the margins by coloring the dashed line black, and we hide them by coloring the lines white. This function is the event handler for the Show Margins/Hide Margins button in the GUI. Here is the button definition:

<INPUT ID="marginbutton" TYPE="BUTTON" VALUE="Hide Margins"
  ONMOUSEUP="ShowHideMargins()">

And here is the event handler:

function ShowHideMargins() {
  if (marginbutton.value == "Show Margins") {
    oMMarkerClass.style.display = "block";
    oContentStyleClass.style.border = "dashed 1 black";
    marginbutton.value = "Hide Margins";
  } else {
      oMMarkerClass.style.display = "none";
      oContentStyleClass.style.border = "dashed 1 white";
      marginbutton.value = "Show Margins";
    }
}

The margin lines pose a difficulty for the printing routine, as we don't want to see the lines in the final printing. For this reason, we hide the lines before printing, and bring them back after. We hide them in the PrintPrep() function:

function PrintPrep() {
  if (oContentStyleClass.style.border = "dashed 1 black")
    reset = true;
  oContentStyleClass.style.border = "dashed 1 white";

  if (layoutrect1.contentDocument.readyState == "complete") {
    PrintNow();
  } else {
      layoutrect1.contentDocument.onreadystatechange =
        PrintWhenContentDocComplete;
    }

  if (reset) oContentStyleClass.style.border = "dashed 1 black";
}

Next: Code Listing


http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 22, 2001
Revised: November 22, 2001

URL: http://www.webreference.com/js/column95/7.html