Closed Bug 363694 Opened 19 years ago Closed 16 years ago

Using Javascript to change the height of a <td> by onmousedown and onmousemove event listeners causes unpredicted behaviour with other table row heights in different

Categories

(Firefox :: General, defect)

2.0 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: a.young, Unassigned)

Details

(Keywords: qawanted, Whiteboard: [CLOSEME 5-15-2010])

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0 When the red filled <td> (id="gap", see below) fires it's onmousedown listener the onmousemove listener function is set allowing the height resize of another <td> (id="r"). By using the following HTML below you will see this. In Internet Explorer this works predictably, but in Firefox different table rows start resizing also, especially the top row. This HTML code is from a web application I am developing and does not contain images/background images, but these too also behave strangely. Below is the HTML I am using: <html> <head> <title></title> <script type="text/JavaScript"> var host = ""; document.onmousemove = resizing; document.onmouseup = endResize; var mousedown = false; var startCoords; var objwWidth; var objwHeight; var mouseNorth; var height3; var tdMinHeight = 25; var width1; var width2; var totalWidth; var tdMinWidth = 250; var div; var frameEvent; var heightTop; var yDiv; var thisCoord; function resizing(e) { if (!mousedown) return; if (!window.event && !e) e = evt; if (mouseNorth) resizingY(e); else resizingX(e); }; function resizingX(e) { var thisCoord = getMouseXY(e); var changeInX = thisCoord[0] - startCoords[0]; var newToolbarWidth = parseInt(toolbarStartWidth - changeInX); var newGapWidth = parseInt(gapStartWidth + changeInX); if (newToolbarWidth < tdMinWidth) { newToolbarWidth = tdMinWidth; newGapWidth = document.getElementById("gap").offsetWidth; } if (newGapWidth < tdMinWidth) { newGapWidth = tdMinWidth; newToolbarWidth = document.getElementById("toolbar").offsetWidth; } setToolbarGapWidth(newToolbarWidth, newGapWidth); }; function setToolbarGapWidth(t, g) { try { document.getElementById("toolbar").style.width = t + "px"; document.getElementById("gap").style.width = g + "px"; } catch (ex) {} }; function resizingY(e) { //document.getElementById("test").style.display = "none"; document.getElementById("r").style.background = "none"; document.getElementById("actions2").style.background = "none"; var thisCoordY = getMouseXY(e); div.style.cursor = "n-resize"; var changeInY = (thisCoordY[1]-startCoords[1]); var height1 = parseInt(document.getElementById("r").offsetHeight); var height2 = parseInt(document.getElementById("task_td").offsetHeight); var height3 = parseInt(document.getElementById("gap").offsetHeight); var endResultY = (rHeight + changeInY); endResultY = (endResultY < tdMinHeight) ? tdMinHeight : endResultY; endResultY = (endResultY > (totalHeight - height3) - tdMinHeight) ? (totalHeight - height3 - tdMinHeight): endResultY; var changeResult = (totalHeight - height1 - height3); changeResult = (changeResult < tdMinHeight) ? tdMinHeight : changeResult; changeResult = (changeResult > (totalHeight - height3) - tdMinHeight) ? (totalHeight - height3 - tdMinHeight): changeResult; document.getElementById("miniDiv").style.height = (endResultY) + "px"; setRHeight(endResultY); }; function setRHeight(h) { document.getElementById("r").style.height = h + "px"; document.getElementById("row_zero").style.height = "20px"; document.getElementById("row_one").style.height = "20px"; document.getElementById("row_two").style.height = "20px"; document.getElementById("task_td").style.height = "auto"; }; function bigDiv(evStr,func,fs){ if (typeof func == "function"){ var fs = func.toString(); var func = fs.substring(fs.indexOf("n ") + 2,fs.indexOf("(")); } var funcList = func.split("|"); var evList = evStr.split("|"); var offsetw = parseInt(getOffsetFromBody(document.getElementById("fixTD")).top); div = document.createElement("div"); div.id = "wholeDiv"; div.style.position = "absolute"; div.style.width = "100%"; div.style.height = "100%"; var loc = host + "../../images/blank.gif"; div.style.background = "url('" + loc + "') repeat"; div.style.top = "0px"; div.style.left = "0px"; div.style.zIndex = "888"; for(var t=0; t < funcList.length; t++){ if (document.all) div.attachEvent("on" + evList[t], eval(funcList[t])); else div.addEventListener(evList[t], eval(funcList[t]), false); document.getElementsByTagName("body")[0].appendChild(div); } return false; } function killBigDiv(){ try { var todelete = document.getElementById("wholeDiv"); todelete.parentNode.removeChild(todelete); } catch(ex) {} } function contextOff(){ try { window.top.document.getElementById("contextMenu").style.display = "none"; setTimeout("switchSelects(true,true)",20); killBigDiv(); } catch(ex) {} } var mousedown = false; var startCoords; function startResize(e) { mousedown = true; startCoords = getMouseXY(e); fixTDWidth = parseInt(document.getElementById("fixTD").style.width); rHeight = parseInt(document.getElementById("r").offsetHeight); bigDiv("mouseup",endResize) var loc = host + "../../images/blank.gif"; yDiv = document.createElement("div"); yDiv.id = "miniDiv"; yDiv.style.position = "absolute"; yDiv.style.width = document.getElementById("r").offsetWidth; yDiv.style.top = parseInt(getOffsetFromBody(document.getElementById("fixTD")).top) + "px"; yDiv.style.bottom = startCoords[1] + "px"; yDiv.style.left = "0px"; yDiv.style.zIndex = "9998"; yDiv.style.background = "url('" + loc + "') repeat"; if (document.all) div.attachEvent("onmouseup", endResize); else div.addEventListener("mouseup", endResize, false); document.getElementsByTagName("body")[0].appendChild(yDiv); }; function endResize(e) { mDown = false; mousedown = false; killBigDiv(); try { var todelete = document.getElementById("miniDiv"); todelete.parentNode.removeChild(todelete); document.getElementById("test").style.display = "block"; document.getElementById("r").style.visibility = ""; document.getElementById("task_td").style.visibility = ""; } catch(ex) {} sizing(); updateResizeToCookie(); }; function sizing() { if (document.all) { Sheight = ( window.document.body.offsetHeight >= 0) ? window.document.body.offsetHeight : 0; Swidth = (document.body.offsetWidth >= 0) ? document.body.offsetWidth : 0; } else { Sheight = (window.innerHeight >= 0) ? window.innerHeight : 0; Swidth = (window.innerWidth >= 0) ? window.innerWidth : 0; Mheight = parseInt(Sheight - 50); } Mheight = (Sheight - 50); }; // Get co-ordinates of an element on the screen function getOffsetFromBody(el) { obj = el; objWidth = obj.offsetWidth; objHeight = obj.offsetHeight; // Find the element's offsetTop and offsetLeft relative to the BODY tag. objLeft = obj.offsetLeft; objTop = obj.offsetTop; objParent = obj.offsetParent; while( objParent.tagName.toUpperCase() != "BODY" ){ objLeft += objParent.offsetLeft; objTop += objParent.offsetTop; objParent = objParent.offsetParent; } var rtObj = new Object(); rtObj.top = objTop; rtObj.left = objLeft; rtObj.width = objWidth; rtObj.height = objHeight; return rtObj; } function updateResizeToCookie() { try{ var rHeight = parseInt(document.getElementById("r").style.height); var toolbarWidth = parseInt(document.getElementById("toolbar").style.width); var gapWidth = parseInt(document.getElementById("gap").style.width); if (!isNaN(rHeight)) setCookie(vUID + "rheight", rHeight); if (!isNaN(toolbarWidth)) setCookie(vUID + "toolbarwidth", toolbarWidth); if (!isNaN(gapWidth)) setCookie(vUID + "gapwidth", gapWidth); }catch(ex){} }; var totalHeight; var c1Height; var mouseNorth = false; function startResizeY(e){ mouseNorth = true; var height1 = parseInt(document.getElementById("r").offsetHeight); var height2 = parseInt(document.getElementById("task_td").offsetHeight); var height3 = parseInt(document.getElementById("gap").offsetHeight); totalHeight = (height1 + height2 + height3); startResize(e); }; var toolbarStartWidth; var gapStartWidth; function startResizeX(e){ mouseNorth = false; toolbarStartWidth = parseInt(document.getElementById("toolbar").offsetWidth); gapStartWidth = parseInt(document.getElementById("gap").offsetWidth); document.getElementById("toolbar").style.width = toolbarStartWidth + "px"; document.getElementById("gap").style.width = gapStartWidth + "px"; startResize(e); }; function getMouseXY(e) { var tempX = 0; var tempY = 0; if (document.all) { try { tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } catch(ex) { tempX = evt.clientX + document.body.scrollLeft; tempY = evt.clientY + document.body.scrollTop; } } else { try { tempX = e.pageX; tempY = e.pageY; } catch(ex) { tempX = evt.clientX + document.body.scrollLeft; tempY = evt.clientY + document.body.scrollTop; } } if (tempX < 0) tempX = 0; if (tempY < 0) tempY = 0; return new Array(tempX, tempY); }; </script> </head> <body class="parent" style="text-align:center;"> <table id="trentMainTable" cellpadding="0" cellspacing="0" border="2" style="border:0px; width: 100%; height: 100%;font-size:.7em;"> <tr id="row_zero"> <td style="display:none;border:0px" id="sidebar" rowspan="7" valign="top"> <table height="100%" cellpadding="0" cellspacing="0" width="160"> <tr> <td style="height:16px;margin:0px;padding:4px;border-right:0px;border-top:1px solid white;border-bottom:2px inset white; height:2em"> <select id="sidePaneSelect" style="font-weight:bold;" onchange="changeSidePaneContent(this)"> <option value="workflow">To do list</option> <option value="settings">My Settings</option> </select> </td> <td style="border:0px;border-top:1px solid white;border-bottom:2px inset white;" align="right"> <a href="javascript:void(0)" target="searchRes" onclick="sidePane(event)">Close<img src="../../images/close_window2.gif" align="absmiddle" height="16" width="16"></a> </td> </tr> <tr> <td colspan="2" id="sidePaneContainer" style="width: 160px;border:0px"> <div style="position: relative; height: 100%; width: 100% "> <iframe name="sidePane1" style="visibility:visible;width:160px" class="rep" src="about:blank" frameborder="0" ></iframe> <iframe name="sidePane2" style="visibility:hidden;width:160px" class="rep" src="about:blank" frameborder="0" ></iframe> </div> </td> </tr> </table> </td> <td style="display:none;" id="sidebar_handle" rowspan="7"> <div></div> </td> <td colspan="7" id="topRow" style="border:0px solid red " height="30"> <table width="100% " > <tr> <td id="debug" valign="middle" style="border:0px; height: 5%; width:250px"> <table cellpadding="0" cellspacing="0"> <tr> <td style="border:0px" valign="middle"> <a href="" style="visibility:hidden" id="email_link"></a> <div class="t_logo" onclick="showAbout(event)" style="width:74px;height:40px;background-image: url(http://www.google.co.uk/logos/edvard_munch.gif)" title="Click for Trent information" /> </td> <td style="padding-left:4px;border:0px" valign="middle"> <span></span> </td> </tr> </table> </td> <td style="border:0px" align="right"> <table cellpadding="0" cellspacing="0"> <tr valign="middle"> <td style="border:0px;" width='15%' align="left" id="edtd"> <input title='Effective date' onselectstart='return true' accesskey="E" onblur="makeDate(this)" ondblclick='popUpCalendar(this, this, "dd/mm/yyyy")' class="text" id="dX" name="date" type="text" value="12/12/2006" size="10" maxlength="10" style="display: none;color:navy;font-weight: bold; background:#ffff99;font-size:13px;width:100px"/> </td> <td style="border:0px;" width='15%' align="left"> <a target="searchRes" onclick="effDate(false)" style="visibility:hidden;color:darkgreen;white-space:nowrap;" href="javascript:void(0)" id="aX"><img height="20" width="20" hspace="2" align="absmiddle" src="../../images/confirm_date.gif" />Confirm effective date</a> <a target="searchRes" onclick="effDate()" id="aXL" href="javascript:void(0)" style="visibility:hidden;color:darkred;white-space:nowrap;">Cancel</a> </td> <td align='right' style='border:0px'> <table> <tr> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> <td rowspan="2" style="border:0px;white-space:nowrap;background:url(../../images/vr.gif) repeat-y center" align="center">&nbsp;</td> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> <td rowspan="2" style="border:0px;white-space:nowrap;background:url(../../images/vr.gif) repeat-y center" align="center">&nbsp;</td> <td rowspan="2" style="border:0px;white-space:nowrap;" align="center"></td> </tr> </table> </td> <!-- </tr> --> </tr> </table> </td> </tr> </table> </td> </tr> <tr valign="middle" id="row_one" onselectstart='return false;'> <th colspan="6" width="100%" align="left" nowrap id="bch" style=""> <div id="breadcrumbs"></div> </th> </tr> <tr style="height:20px" valign="middle" id="row_two"> <td width="3" style="border:0px;width:3px;" rowspan="4" id="c1" > <img src="../../images/spacer.gif" width="3" height="1" style="display: none" /> </td> <td align="right" colspan="2" style="border:0px;padding:0px;border-left: 1px solid #6699CC;" id="fixTD"> <table cellpadding="0" cellspacing="0" style="width: 100%" class="fixTABLE" id="fixtable"> <tr valign="middle"> <td style="visibility:hidden;border:0px; width: 15px" align="left"> <input id="searchRB" type="radio" name="sT" onclick="change(event, true)" checked="checked" /> </td> <td align="center" id="searchLabel" style="visibility:hidden;border:0px;font-weight: bold; width: 40px"> <span>Search</span> </td> <td style="visibility:hidden;border:0px; width: 15px" align="left"> <input id="groupRB" type="radio" onclick="change(event, false)" name="sT" /> </td> <td style="visibility:hidden;border:0px; width: 100px;" nowrap="nowrap" align="left" id="groupLabel"> <span>Smart groups</span> </td> <td nowrap="nowrap" align="right" id="searchTypeLabel" style="visibility:hidden;border:0px;"> <a id="adv_search_label" href="javascript:void(0);" target="searchRes" onclick="aSearch(true)" accesskey="A" style="font-weight:normal;cursor:pointer">Advanced</a>&nbsp; </td> <td align="right" id="curve1" style="border:0px;width:27px;height:20px;overflow:hidden;"> <img src="../../images/spacer.gif" width="28" height="20" style="display: none" /> </td> </tr> </table> </td> <td align="right" valign="middle" id ="toolbar" style="border:0px;"> <table cellpadding="0" cellspacing="0" border="0" width="100% "> <tr style="border:0px;"> <td style="border:0px;" id="toolbarTD" align="right">&nbsp;</td> <td id='curve2' style="border:0px;" align="right" width="25"> <img src="../images/spacer.gif" height="20" width="25" style="display: none" /> </td> </tr> </table> </td> <td id="c3" style="width:3px;border:0px;" rowspan="4"> <img src="../images/spacer.gif" height="2" width="3" /> </td> </tr> <tr> <td id="r" valign="top"> <div style="position:relative;height:100%;width:100%"> <iframe id="results" name="results" class="rep" src="http://www.google.com" frameborder="0" ></iframe> </div> </td> <td id="c2" style="width:3px;border:0px;border-right:1px solid #6699CC;" rowspan="3"> <img src="../../images/spacer.gif" width="3" height="1" /> </td> <td id="info" rowspan="3" style="border-left:0px;position:relative;top:0px;left:0px"> <div id="slidingsearch" style="width: 181px; height: 300px; position: absolute; z-index: 200; right: -110%; display: none;background:#ffffff"> <form onsubmit="searcher(this);return false;" name="sideSearch"> <table cellpadding="3" cellspacing="0" style="background:#ffffff;border-top: 1px solid #0052CC; border-bottom: 1px solid #0052CC; border-left: 1px solid #0052CC; width: 180px; height: 100%"> <tr style="background:buttonface;"> <td height="10" align="left" valign="middle" > <span id="sideSearchLabel" style="font-weight:bold"></span> </td> <td height="10" align="right" valign="middle"> <a target="searchRes" href="javascript:void(0)" onclick="moveSearch()" >Close<img src="../../images/close_window2.gif" width="16" height="16" align="absmiddle" /></a> <iframe name="searchRes" id="searchRes" frameborder="0" style="width:0px; height:0px; border: 0px" src="about:blank"></iframe> </td> </tr> <tr> <td colspan="2" valign="top" style="padding:0px;height:300px"> <div id="sideSearchResults" style="width: 180px; height: 100%; border: 1px solid silver;overflow:auto"></div> </td> </tr> </table> </form> </div> <div id="mainDiv" style="position: relative; height: 100%; width: 100%"> <div class="vResizer" onmousedown="startResizeX(event)" onmouseup="endResize()">&nbsp;</div> <iframe id="main_trnt" name="main_trnt" src="http://www.google.com" frameborder="0" allowtransparency="true" style="width: 100%; height: 100%;"></iframe> <iframe id="notes" name="notes" frameborder="0" src="about:blank"></iframe> <iframe id="attachments" name="attachments" frameborder="0" src="about:blank" style="visibility:hidden;position:absolute;z-index:500;border:0px;height:400px;width:500px;top:0px;right:0px"></iframe> <!-- Extra start --> </div> <!-- Extra end --> </td> </tr> <tr id="actions1" style="height:2%;"> <td id="gap" style="width:250px;padding:4px;;position:relative;top:0px;left:0px;background-color: red"> <div style="width:100%; height:100%;"> <div onselectstart="return false;" style="cursor: n-resize; position:relative; top:0px; height:100%; width:100%;" onmousedown="startResizeY(event)" onmouseup="endResize()"> <a target="searchRes" id="favLink" href="javascript:void(0)" onmousedown="toggleFavourites(event)" ><span style="display:inline">Show all options&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="display:none">Show favourites&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></a> <a target="searchRes" id="folderLink" style="display:none" href="javascript:void(0)" onmousedown="toggleAllFolders(event)" >Expand/Collapse folders</a> <a target="searchRes" href="javascript:void(0)" accesskey="F" onmousedown="findNav(event)" onclick="findNav(event)" style="position:absolute;top:-1px;right:-3px;cursor:pointer" ><img style="display: none" src="../../images/find_nav.gif" title="Find navigation option" /></a> </div> </div> </td> </tr> <tr id="actions2" style="background: #d7def8" height="30% "> <td id="task_td" valign="top" > <div style="position: relative; height: 100%; width: 100%;" id="test"> <iframe id="if_tasks" name="if_tasks" class="rep" src="http://www.google.com" frameborder="0" ></iframe> </div> </td> </tr> <tr id="tabrow" style="display:none"> <td colspan="3" style="padding-right:3px;border-left:0px;border-right:0px;border-bottom:0px;">&nbsp;</td> </tr> </table> <div onclick="fillDD()" id="dd_menu" style="width:120px;font-size:.7em;background: #ffffff;border:1px solid silver;position:absolute;top:0px;left:0px;z-index:600;visibility:hidden"></div> </body> </html> Reproducible: Always Steps to Reproduce: 1. Create an HTML file with the code from the 'Details' 2. When the page is loaded, click and hold the mouse whilst over the red horizontal bar (a <td>) 3. Move the mouse up and down to resize the above and below <td>s. 4. Release mouse button once finished Expected Results: The <td>s above and below the red <td> should resize, leaving all over row heights unchanged.
Having added the HTML and JavaScript for this problem I have realised that there has been some line wrapping... This has caused any JavaScript in the page to failed. Please send a minute going through the JavaScript and correct any errors that the line wrapping might have caused.
Ok, realised you can add attachments to a Bug raised. See the sample HTML source file attached.
Can you make a reduced testcase? The one you've attached is far too complicated.
This bug needs a simplified testcase.
Keywords: qawanted
This bug was reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.3 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME http://www.mozilla.com http://support.mozilla.com/kb/Managing+profiles http://support.mozilla.com/kb/Safe+mode
Whiteboard: [CLOSEME 5-15-2010]
Version: unspecified → 2.0 Branch
No reply, INCOMPLETE. Please retest with Firefox 3.6.x or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: