1 ////////////////////////////////////////////////////////////////////////////////
4 // Revision: $Revision: 1.1 $
5 // Description: JavaScript routine to fix an IE bug regarding the user of
6 // tables in <div>'s that are not flush right
7 // Author: Andrew@DeFaria.com
8 // Created: Wed May 12 13:47:39 PDT 2004
9 // Modified: $Date: 2013/06/12 14:05:47 $
10 // Language: JavaScript
12 // (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ////////////////////////////////////////////////////////////////////////////////
15 function AdjustTableWidth (table_name, width_percentage, margins) {
16 // This function fixes the problem with IE and tables. When a table
17 // is set to say 100% but is in a div that is not flush with the
18 // left side of the browser window, IE does not take into account
19 // the width of the div on the left. This function must be called
20 // after the close of the div that the table is contained in. It
21 // should also be called in the body tag for the onResize event in
22 // case the browser window is resized.
24 // If the browser is not IE and 5 or greater then return
25 if (navigator.userAgent.indexOf ("MSIE") == -1 ||
26 parseInt (navigator.appVersion) >= 5) {
30 // If width_percentage was not passed in then set it to 100%
31 if (width_percentage == "" || width_percentage == null) {
34 width_percentage = width_percentage / 100;
37 // If margins were not set then use 15 pixels
38 if (margins == "" || margins == null) {
43 var table = document.getElementById (table_name);
46 return; // no table, nothing to do!
49 // Get the width of the page in the browser
50 var body_width = document.body.clientWidth;
52 // Get the width of the left portion. Note this is hardcoded to the
53 // value of "leftbar" for the MAPS application
54 var sidebar_width = document.getElementById ("leftbar").clientWidth;
56 // Now compute the new table width by subtracting off the sizes of
57 // the sidebar_width and margins then multiply by the
60 (body_width - sidebar_width - margins) * width_percentage;
61 ;} // AdjustTableWidth