473,785 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bounding a Resizable Table

12 New Member
Hey everyone, thanks for your previous help. My new problem is trying bound this table in Firefox so when you resize via the middle bar it doesn't resize to the right to infinity. Basically, I want these two cells to resize within the screen and not past the right edge of the screen. If you resize to the left, it works perfect and I just need the right to do the same. I hope I explained it well, let me know if anyone needs more clarification.

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title> Dynamic Table </title>
  5. <style type="text/css">
  6. #DragColumn_0
  7. {
  8.      position:relative;
  9.      z-index:5;
  10. }
  11.  
  12. #ContentColumn_1
  13. {
  14.      border: solid 1px black;
  15.      position:absolute;
  16.      overflow:hidden;
  17.      background-color: #eaf4f3; 
  18.      z-index:10
  19. }
  20.  
  21. #DragColumn_1
  22. {
  23.      position:absolute;
  24.      cursor:e-resize;
  25.      z-index:11;
  26. }
  27.  
  28. #ContentColumn_2
  29. {
  30.      border: solid 1px black;
  31.      position:absolute;
  32.      overflow:hidden;
  33.      background-color: #eaf4f3; 
  34.      z-index:10
  35. }
  36.  
  37. #DragColumn_2
  38. {
  39.      position:absolute;
  40.      cursor:e-resize;
  41.      z-index:11;
  42. }
  43. </style>
  44.  
  45. <script type="text/javascript">
  46.  
  47. window.onload = function()
  48. {
  49.      PageSetup();
  50. }
  51.  
  52.  
  53. // global constants
  54. var ZERO_AMOUNT = 0;
  55. var ONE_MILLISECOND = 1;
  56. var SIX_MILLISECONDS = 6;
  57.  
  58. // global variables
  59. var _xMousePosition = 0;
  60. var _yMousePosition = 0;
  61. var _mouseButtonDown = false;
  62.  
  63.  
  64. // event handlers
  65. function MouseMoveHandler(event) {
  66.      var e = event || window.event;
  67.      _xMousePosition = e.clientX + document.body.scrollLeft;
  68.      _yMousePosition = e.clientY + document.body.scrollTop;
  69. }
  70.  
  71. function MouseDownHandler(event) {
  72.      var e = event || window.event;
  73.      var elementID = e.srcElement ? e.srcElement.id : e.target.id;
  74.      var columnIndexValue = elementID.slice(elementID.length-1, elementID.length);
  75.      _mouseButtonDown=true;
  76.      ChangeColumnWidth(columnIndexValue);
  77. }
  78.  
  79. function MouseUpHandler(event){
  80.      var e = event || window.event;
  81.      _mouseButtonDown = false;
  82.      var cursorResetFunctionCall = 'document.body.style.cursor = ""';
  83.      window.setTimeout(cursorResetFunctionCall, SIX_MILLISECONDS);
  84. }
  85.  
  86. function PageSetup()
  87. {
  88.      document.onmousemove = MouseMoveHandler;
  89.      document.onmouseup = MouseUpHandler;
  90.  
  91.      var drag0 = document.getElementById("DragColumn_0");
  92.      var drag1 = document.getElementById("DragColumn_1");
  93.      var drag2 = document.getElementById("DragColumn_2");
  94.      var column1 = document.getElementById("ContentColumn_1");
  95.      var column2 = document.getElementById("ContentColumn_2");
  96.      var colWidth1 = _columnWidthSettings[1];
  97.      var colWidth2 = _columnWidthSettings[2];
  98.  
  99.      drag0.style.left = TABLE_LEFT + "px";
  100.      drag0.style.top = TABLE_TOP + "px";
  101.      drag0.style.height = TABLE_HEIGHT + "px";
  102.  
  103.      column1.style.left = TABLE_LEFT + "px";
  104.      column1.style.width = colWidth1 + "px";
  105.      column1.style.top = TABLE_TOP + "px";
  106.      column1.style.height = TABLE_HEIGHT + "px";
  107.  
  108.      drag1.style.left = (TABLE_LEFT + colWidth1) + "px";
  109.      drag1.style.width = DRAG_WIDTH + "px";
  110.      drag1.style.top = TABLE_TOP + "px";
  111.      drag1.style.height = TABLE_HEIGHT + "px";
  112.      drag1.onmousedown=MouseDownHandler;
  113.  
  114.      column2.style.left = (TABLE_LEFT + colWidth1 + DRAG_WIDTH) + "px";
  115.      column2.style.width = colWidth2 + "px";
  116.      column2.style.top = TABLE_TOP + "px";
  117.      column2.style.height = TABLE_HEIGHT + "px";
  118.  
  119.      drag2.style.left = (TABLE_LEFT + colWidth1 + DRAG_WIDTH + colWidth2) + "px";
  120.      drag2.style.width = DRAG_WIDTH + "px";
  121.      drag2.style.top = TABLE_TOP + "px";
  122.      drag2.style.height = TABLE_HEIGHT + "px";
  123.      drag2.onmousedown=MouseDownHandler;
  124. }
  125.  
  126.  
  127.  
  128. function ChangeColumnWidth(columnIndexValue){
  129.      //alert("You reached to the top of the ChangeColumnWidth method!");
  130.      var columnIndex = parseInt(columnIndexValue);
  131.  
  132.      if(columnIndex >= 0){
  133.           document.body.style.cursor = "e-resize";
  134.  
  135.           var previousDragColumn = document.getElementById("DragColumn_" + (columnIndex-1));
  136.           var currentDragColumn = document.getElementById("DragColumn_" + columnIndex);
  137.           var currentContentColumn = document.getElementById("ContentColumn_" + columnIndex);
  138.  
  139.           var leftString = previousDragColumn.style["left"] ? previousDragColumn.style["left"]:previousDragColumn.currentStyle["left"];
  140.  
  141.           var previousDragLeftColumnPosition = parseInt(leftString.slice(0,leftString.length-2));
  142.           var previousDragRightColumnPosition;
  143.           if(columnIndex > 1)
  144.           {
  145.                previousDragRightColumnPosition = previousDragLeftColumnPosition + DRAG_WIDTH;
  146.           }
  147.           else
  148.           {
  149.                previousDragRightColumnPosition = previousDragLeftColumnPosition;
  150.           }
  151.  
  152.           var distanceFromMouseToPreviousColumn = _xMousePosition - (previousDragRightColumnPosition);
  153.           var dragColumnLeftPosition = 0;
  154.  
  155.           if(distanceFromMouseToPreviousColumn < MINIMUM_ALLOWED_WIDTH)
  156.           {
  157.                _columnWidthSettings[columnIndex] = MINIMUM_ALLOWED_WIDTH;
  158.                dragColumnLeftPosition = previousDragLeftColumnPosition + MINIMUM_ALLOWED_WIDTH;
  159.           }
  160.           else
  161.           {
  162.                _columnWidthSettings[columnIndex] = distanceFromMouseToPreviousColumn;
  163.                dragColumnLeftPosition = _xMousePosition;
  164.           }
  165.  
  166.           currentContentColumn.style.width = (_columnWidthSettings[columnIndex]) + "px";
  167.           currentDragColumn.style.left = dragColumnLeftPosition + "px";
  168.           currentDragColumn.style.width = DRAG_WIDTH + "px";
  169.  
  170.  
  171.           for(iteration=(columnIndex+1); iteration<_columnWidthSettings.length; iteration++)
  172.           {
  173.                var nextDragColumn = document.getElementById("DragColumn_" + iteration);
  174.                var nextContentColumn = document.getElementById("ContentColumn_" + iteration);
  175.  
  176.                nextContentColumn.style.left = (dragColumnLeftPosition + DRAG_WIDTH) + "px";
  177.                nextContentColumn.style.width = _columnWidthSettings[iteration] + "px";
  178.                nextDragColumn.style.left = (dragColumnLeftPosition + DRAG_WIDTH + _columnWidthSettings[iteration]) + "px";
  179.                nextDragColumn.style.width = DRAG_WIDTH + "px";
  180.  
  181.                dragColumnLeftPosition += DRAG_WIDTH + _columnWidthSettings[iteration];
  182.           }
  183.  
  184.      }
  185.  
  186.      var recursiveFunctionCall = "ChangeColumnWidth('"+columnIndex+"')";
  187.  
  188.      if(_mouseButtonDown)
  189.      {
  190.           window.setTimeout(recursiveFunctionCall, ONE_MILLISECOND);
  191.      }
  192. }
  193.  
  194.  
  195. // CUSTOMIZABLE LAYOUT SETTINGS - FEEL FREE TO MODIFY THESE.
  196. var MINIMUM_ALLOWED_WIDTH = 30;
  197. var MINIMUM_ALLOWED_HEIGHT = 30;
  198. var TABLE_LEFT = 0;
  199. var TABLE_TOP = 0;
  200. var TABLE_HEIGHT = window.innerHeight;
  201. var DRAG_WIDTH = 1;
  202. var halfscreenwidth = document.documentElement.clientWidth/2;
  203. var _columnWidthSettings = new Array(0, halfscreenwidth, halfscreenwidth);
  204.  
  205. </script>
  206. </head>
  207.  
  208.  
  209. <body>
  210.  
  211. <div id="DragColumn_0"></div>
  212. <div id="ContentColumn_1" align=center valign=middle><iframe frameborder="0" src="" width=40% height=100%></iframe></div>
  213. <div id="DragColumn_1"></div>
  214. <div id="ContentColumn_2" align=center valign=middle><iframe frameborder="0" src="" width=40% height=100%></iframe></div>
  215. <div id="DragColumn_2"></div>
  216.  
  217. </body>
  218. </html>
May 24 '07 #1
1 1507
acoder
16,027 Recognized Expert Moderator MVP
This viewport link may help.
Jan 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1935
by: ljb | last post by:
Using PHP-4.3.11 with GD extension, bundled GD library, and freetype-2.1.9 (with X.org 6.8.1). I can't get the TrueType Font (TTF) bounding box to come out right. Whether using imagettftext() or imagettfbbox(), for some angles of text (like 45 degrees), the box comes back in the wrong place. Sample code below; just change the $font assignment to point to a TTF font file. You should see a text string with a box around it, but my box isn't...
12
2287
by: superprad | last post by:
If I have ex: x = , , , ] what I want is a boundingbox over the region where we find clusters of 1's.So for instance in the above list first 3 roes and colums have 1's so the area of that box is 3x3 so my final array should have an array of approx areas of clusters of
0
2603
by: nor | last post by:
Hi, I’m doing a project to recognize shape of object. I had completed filtering part and now I’m starting for recognition part. First, I want to create bounding box of the object in the image so the bounding box will appear automatically around the object detected in the image. However, I'm stuck in the process. Any body could help me please… :o I’m doing the programming in C#.
1
16975
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot examples I found on the web. Works in IE and mozilla. http://www.imaputz.com/cssStuff/bigFourVersion.html
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.