1 ////////////////////////////////////////////////////////////////////////////////
4 // Description: JavaScript routine to fix an IE bug regarding the user of
5 // tables in <div>'s that are not flush right
6 // Author: Andrew@DeFaria.com
7 // Created: Wed May 12 13:47:39 PDT 2004
9 // Language: JavaScript
11 // (c) Copyright 2003, Andrew@DeFaria.com, all rights reserved.
13 ////////////////////////////////////////////////////////////////////////////////
14 function AdjustTableWidth (table_name, width_percentage, margins) {
15 // This function fixes the problem with IE and tables. When a table
16 // is set to say 100% but is in a div that is not flush with the
17 // left side of the browser window, IE does not take into account
18 // the width of the div on the left. This function must be called
19 // after the close of the div that the table is contained in. It
20 // should also be called in the body tag for the onResize event in
21 // case the browser window is resized.
23 // If the browser is not IE and 5 or greater then return
24 alert ("enter AdjustTableWidth");
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 == null || width_percentage == "") {
34 width_percentage = width_percentage / 100;
37 // If margins were not set then use 15 pixels
38 if (margins == null || margins == "") {
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 alert ("Locating 'leftbar'...");
53 // Get the width of the left portion. Note this is hardcoded to the
54 // value of "leftbar" for the MAPS application
55 var sidebar_width = document.getElementByClass ("leftbar").clientWidth;
58 // Now compute the new table width by subtracting off the sizes of
59 // the sidebar_width and margins then multiply by the
62 (body_width - sidebar_width - margins) * width_percentage;
63 ;} // AdjustTableWidth