473,700 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

slow response in table cells <TD> to mouseover with IE6 but fine inFirefox.

I'm a relatively slow response of table cells changing their
background color with mouseover/our in IE6 (Win 2K) but the response
is fine (fast) in Firefox. Why? The code is below. Sorry about the
length.

<html>
<head>
<title>Rapid Blocking Interface</title>
<style>
.calendar {
position:relati ve;
cursor:default;
}
.calendarHeader {
background-color:lightgree n;
text-align:center;
font-family:sans-serif;
width:140;
}
.calendarRow {
height:30;
}
#calendar1 {
top:20;
left:10;
background-color:white;
}
#appointment {
position:absolu te;
width:300;
height:200;
background-color:lightyell ow;
border:2px black solid;
font-weight:bold;
font-family:sans-serif;
visibility:hidd en;
}
#output {
position:absolu te;
top:35;
left:750
}
#clear {
position:absolu te;
top:460;
left:750;
width:80;
background-color:lightgrey ;
border:2px black solid;
color:black;
text-align:center;
font-weight:bold;
font-family:sans-serif;
cursor:default;
}
</style>
</head>
<body>
<table id='calendar1' class='calendar ' border='1' cellpadding='0'
cellspacing='0' >
<tr>
<td class="calendar Header">0</td>
<td class="calendar Header">1</td>
<td class="calendar Header">2</td>
<td class="calendar Header">3</td>
<td class="calendar Header">4</td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class='calendar Row'>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>

<div id="output"><te xtarea cols=25 rows=25></textarea></div>
<div
id="clear"
onmousedown="re turn false;"
onclick="docume nt.getElementBy Id('output').fi rstChild.value = '';"
>
CLEAR
</div>
<div
id="appointment "
class="draggabl e"
onclick="this.s tyle.visibility = 'hidden';"
>
&nbsp;&nbsp;
</div>

<script>
(function () {
var calendar = document.getEle mentById('calen dar1'),
rows = calendar.getEle mentsByTagName( 'tr'),
slots = calendar.getEle mentsByTagName( 'td');

/*debug*/ var output = document.getEle mentById('outpu t').firstChild;
/*debug*/ output.value = '';

var apt = document.getEle mentById('appoi ntment');
apt.appendChild (document.creat eTextNode(''));

function addSlotControl( el) {
var sc = document.create Element('div');
sc.style.positi on='relative';
sc.style.backgr oundColor='ligh tgrey';
sc.style.border Width='1px';
sc.style.border Color='black';
sc.style.border Style='solid';
sc.style.margin ='0px';
sc.style.paddin g='0px';
sc.style.visibi lity='hidden';
sc.style.top=0;
sc.style.left=1 00;
sc.style.height =13;
sc.style.width= 28;
sc.style.textAl ign='center';
sc.style.fontSi ze=10;
sc.style.fontFa mily='sans-serif';
sc.appendChild( document.create TextNode('SC')) ;
el.appendChild( sc);
}

var selectMode = false,
initialControlS tate,
columnSelected,
firstRowSelecte d,
previousRowSele cted,
lastRowSelected ,
selectionCancel led,
downOn = null;

function mousedownHandle r(e) {
e.returnValue = false;
if (e.preventDefau lt) {e.preventDefau lt();}

var target = getEventTarget( e);
if (target.nodeNam e !== 'DIV') {
if (target.nodeNam e === 'TD') {
downOn = target;
}
return false;
}
addEvent(calend ar, 'selectstart', selectStartHand ler, false);

var slot = target.parentNo de;
selectMode = true;
selectionCancel led = false;
initialControlS tate = target.style.ba ckgroundColor;
columnSelected = slot.cellIndex;
firstRowSelecte d = lastRowSelected = slot.parentNode .rowIndex;

slot.firstChild .style.visibili ty = 'hidden';
slot.style.back groundColor
= (initialControl State === 'lightgrey')? '#FF9966':'#FFC C99';

return false;
}

/
*************** *************** *************** *************** ***********
Distinguishing onmouseover/out of child elements from those of the
parent element.

Mouseover fires first but mouseout fires when the mouse moves over
the child (DIV) element. The problem is not just about bubbling,
because when you move the mouse over the DIV, you are not moving out
of anything contained in the table cell (TD) nor are you moving out
of the area contained by the TD. A mouseout event fires simply
because a mouseover event fires for another element.

See: http://www.faqts.com/knowledge_base/view.phtml/aid/1606
http://www.quirksmode.org/js/events_mouse.html
http://www.dynamic-tools.net/toolbox...eLeaveOrEnter/

Also, the try/catch blocks handle a related version of the

"Permission denied to get property HTMLDivElement. parentNode"

bug in Firefox/Mozilla. Moving the mouse cursor fast enough from the
grid over the textarea will cause this bug to occur.

See: https://bugzilla.mozilla.org/show_bug.cgi?id=208427
https://bugzilla.mozilla.org/show_bug.cgi?id=214340
*************** *************** *************** *************** ***********/

function mouseoverHandle r(e) {
if (selectionCance lled) { return; }

var err, target = getEventTarget( e);

if (target.nodeNam e !== 'TD'
&&
target.nodeName !== 'DIV') { return; } // Mouse did not enter
// calendar slot.

/** Get the element the mouse comes from. **/

var relTarget = e.relatedTarget || e.fromElement;
try {
if (relTarget.pare ntNode === target // Mouse moves
|| // from child
target.parentNo de === relTarget) { return; } // over parent
} // target element
catch (err) { return; } // or vice versa.

/** Mouse actually entered TD. Handle event. **/

if (target.nodeNam e === 'DIV') { target = target.parentNo de; }
if (target.classNa me === 'calendarHeader ') { // Mouse moved into
if (selectMode) { cancelSelection (); } // calendar header.
}
else if (!selectMode) {
target.style.ba ckgroundColor
= (target.firstCh ild.style.backg roundColor === 'lightgrey')?
'lightyellow':' lightgrey';
target.firstChi ld.style.visibi lity = "visible";
}
else if (target.cellInd ex === columnSelected)
{
// First detect missed mouse events with fast cursor movement.

var rowT = target.parentNo de.rowIndex,
rowRT = (relTarget.node Name === 'TD')?
relTarget.paren tNode.rowIndex: relTarget.paren tNode.parentNod e.rowIndex;

if (rowRT !== undefined
&&
Math.abs(rowRT - rowT) 1) // Cancel if slot events missed.
{
cancelSelection ();

return;
}

previousRowSele cted = lastRowSelected ;
lastRowSelected = target.parentNo de.rowIndex;
var slot,
sc,
vector = Math.abs(lastRo wSelected - firstRowSelecte d) -
Math.abs(previo usRowSelected - firstRowSelecte d);

if (vector 0) // Moving away from first selection.
{
sc = target.firstChi ld;
sc.style.visibi lity = 'hidden';
target.style.ba ckgroundColor
= (sc.style.backg roundColor === 'lightgrey')?
'#C6E2FF':'#9FB 6CD';
}
else if (vector < 0) // Moving toward first selection.
{
slot = rows[previousRowSele cted].cells[columnSelected];
slot.style.back groundColor
= (slot.firstChil d.style.backgro undColor === 'lightgrey')?
'white':'lightg rey';
}
}

}

function mouseoutHandler (e) {
if (selectionCance lled) { return;}

var err, target = getEventTarget( e);

if (target.nodeNam e !== 'TD'
&&
target.nodeName !== 'DIV') { return; } // Mouse did not exit
// calendar slot.
/** Get the element the mouse goes to **/

var relTarget = e.relatedTarget || e.toElement;
try { // Mouse moves
if (relTarget.pare ntNode === target // to child
|| // out from
target.parentNo de === relTarget) { return; } // parent target
} // or vice versa.
catch (err) {
if (!selectMode
&&
target.style.ba ckgroundColor) // IE related issue.
{

target.style.ba ckgroundColor
= (target.firstCh ild.style.backg roundColor === 'lightgrey')?
'white':'lightg rey';
target.firstChi ld.style.visibi lity = "hidden";
}

return;
}

/** Mouse actually left TD. Handle event. **/

if (target.nodeNam e === 'DIV') { target = target.parentNo de; }
if (target.classNa me === 'calendarHeader ') { return; }

if (!selectMode) {
target.style.ba ckgroundColor
= (target.firstCh ild.style.backg roundColor === 'lightgrey')?
'white':'lightg rey';
target.firstChi ld.style.visibi lity = "hidden";
}
else if (relTarget.cell Index !== columnSelected)
{ cancelSelection (); }

}

function mouseupHandler( e) {
var coord, target = getEventTarget( e);

if (target.nodeNam e === 'DIV')
{
target = target.parentNo de;
}
if (target.nodeNam e === 'TD'
&&
target.parentNo de.className === 'calendarRow')
{
if (selectMode) {
if (!selectionCanc elled) { finalizeSelecti on(); }
}
else if (downOn === target) {
if (target.style.b ackgroundColor !== 'lightgrey') {
apt.innerHTML = '&nbsp;&nbsp; ' + target.parentNo de.rowIndex + ',
'+ target.cellInde x;
apt.style.left = e.pageX || e.clientX + document.body.s crollLeft
+ document.body.c lientLeft;
apt.style.top = e.pageY || e.clientY + document.body.s crollTop +
document.body.c lientTop;
apt.style.visib ility = 'visible';
}
downOn = null;
}
}
selectMode = selectionCancel led = false; // Whether true or false,
calendar.onsele ctstart = null; // set to false.
}

function selectStartHand ler(e) {
e.returnValue = false;
return false;
}

function finalizeSelecti on() {
var c = columnSelected, r, slot, slotBgC, scBgC;

if (initialControl State === 'lightgrey') {
slotBgC = 'lightgrey';
scBgC = 'white';
}
else {
slotBgC = 'white';
scBgC = 'lightgrey';
}
if (firstRowSelect ed <= lastRowSelected ) {
for (r = firstRowSelecte d; r <= lastRowSelected ; r++) {
(slot = rows[r].cells[c]).style.backgro undColor = slotBgC;
slot.firstChild .style.backgrou ndColor = scBgC;
}
}
else {
for (r = firstRowSelecte d; r >= lastRowSelected ; r--) {
(slot = rows[r].cells[c]).style.backgro undColor = slotBgC;
slot.firstChild .style.backgrou ndColor = scBgC;
}
}
initialControlS tate = null;
firstRowSelecte d = null;
lastRowSelected = null;
columnSelected = null;
}

function cancelSelection () {
var c = columnSelected, r, slot, slotBgC;

selectionCancel led = true;

if (firstRowSelect ed <= lastRowSelected ) {
for (r = firstRowSelecte d; r <= lastRowSelected ; r++) {
slotBgC = ((slot =
rows[r].cells[c]).firstChild.st yle.backgroundC olor === 'white')?
'lightgrey':'wh ite';
slot.style.back groundColor = slotBgC;
}
}
else {
for (r = firstRowSelecte d; r >= lastRowSelected ; r--) {
slotBgC = ((slot =
rows[r].cells[c]).firstChild.st yle.backgroundC olor === 'white')?
'lightgrey':'wh ite';
slot.style.back groundColor = slotBgC;
}
}
initialControlS tate = null;
firstRowSelecte d = null;
lastRowSelected = null;
columnSelected = null;
}

function elXY(el) {
var c = {x:0, y:0};
while (el) {
c.x += el.offsetLeft;
c.y += el.offsetTop;
el = el.offsetParent ;
}
return c;
}

function evtXY(e) {
return {
x:e.offsetX || e.clientX + window.pageXOff set,
y:e.offsetY || e.clientY + window.pageYOff set
}
}

function addEvent(el, evtType, listener, captures) {
if (el.addEventLis tener) {
el.addEventList ener(evtType, listener, captures);
return true;
}
else if (el.attachEvent ) {
return el.attachEvent( 'on' + evtType, listener);
}
else {
el['on' + evtType] = listener;
}
}

function getEventTarget( e) {
return (window.event)? window.event.sr cElement:(e)? e.target:null;
}

function stopBubbling(e) {
if (!e) { var e = window.event; }
e.cancelBubble = true;
if (e.stopPropagat ion) { e.stopPropagati on(); }
}

for (var i=0; i < slots.length; i++) {
if (slots[i].className !== 'calendarHeader ') {
addSlotControl( slots[i]); // Add slot control as
} // slots first child.
}
addEvent(docume nt, 'mouseup', mouseupHandler, false);
addEvent(calend ar, 'mousedown', mousedownHandle r, false);
addEvent(calend ar, 'mouseover', mouseoverHandle r, false);
addEvent(calend ar, 'mouseout', mouseoutHandler , false);
})();
</script>
</body>
</html>
Jun 1 '08 #1
2 3023
Works same in both browsers for me
Jun 1 '08 #2
On Jun 1, 5:20 am, yukabuk <yuka...@google mail.comwrote:
Works same in both browsers for me
yukabuk, I need to test this also on very old computers like 500 Mhz /
256 MB systems. I'm see a big difference on the same system in how
fast Firefox and IE respond to moving the cursor over the tables
cells. IE is quite slow, I'm wondering why and what can be done about
it.

Thanks.
Jun 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3577
by: A Web Master | last post by:
As a mean of not having to use Framesets/Frames with all the bad side effects/workarounds that come with them, I want to know if it is possible to code a scrolling veritcal bar into a table <TD> ? If so, how ? I am coding my client's WEB site in ASP.
1
2666
by: Stan Brown | last post by:
In looking over my style sheet http://www.acad.sunytccc.edu/instruct/sbrown/screen.css I see that I have identical fonts and colors set on table and td elements. Is there any reason to do this, or is it a bit of cargo-cultery that I put in there when I was first starting out? As far as I can see, if I've styled td and th there's no need to style table, as far as font and color go. (Other properties like
2
6169
by: Pete Kipe | last post by:
I'm not a JavaScript programmer...but I'm trying to put together a simple menu system for a new website and need a little help. I have the following script: <SCRIPT language=javascript> <!-- Hide JavaScript from Java-Impaired Browsers function NavRollOver(oTd) {if (!oTd.contains(event.fromElement)) {oTd.bgColor="#CC0000";}} function NavRollOut(oTd) {if (!oTd.contains(event.toElement))
4
4063
by: dropdeadster | last post by:
Trying to line up a tic-tac-toe board type grid of images using style= tags to <img inside a table TD but it's not working, I get more like a set of steps, can I get an explanation of what's wrong with this and how to do it correctly?: <table border="1"> <tr> <td valign="top" align="left">
3
1995
by: Manish Sawjiani | last post by:
Dear experts i have just migrated from asp to asp.net and i am missing the loop for creating tables. while in asp one could just start a loop anywhere withing <% %is this out of style in the .Net Scenario? Thanks Manish --
4
17613
by: Jason | last post by:
Is that possible? How? <td > <asp:Label ID="StartDateLabel" runat="server" Text="Start Date:"> <asp:imagebutton ID="Imagebutton1" width=18 Height=18 CommandName=SetDate imageUrl="../cal.jpg" runat=server /> </asp:Label> </td> <td >
7
2788
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why. $test=~/<tr><td>(.*)<\/td><\/td>(.*)<\/td><\/tr>/ms; <tr><td>station</td> <td>station number/identification, see chart above: <br> B = GoMoos buoy B location<br> S = New Scantum at the southern edge Jefferys Ledge</td></tr>.
4
555
by: markszlazak | last post by:
I'm a relatively slow response of table cells changing their background color with mouseover/our in IE6 (Win 2K) but the response is fine (fast) in Firefox. Why? The code is below. Sorry about the length. <html> <head> <title>Rapid Blocking Interface</title> <style> .calendar {
0
1848
by: =?Utf-8?B?R3JlZw==?= | last post by:
I've created my table and alli is fine. I name my <tdtags to make them easier to identify when my table gets large. Anyway, I am naming as such: <td id="cellName" > Now, sometimes when make a change to a control my whole table gets resized and screwed up from some reason. I may have a column with a width of 75px, but it will appear so narrow it is hardly visible. Anyway, in these cases I undo what made this happen and the table fixes...
0
8729
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
8648
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9217
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
8974
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
8928
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
7815
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5903
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();...
1
3094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.