View Full Version : td and onClick
03-18-2003, 04:56 PM
I am dynamically writing out a table and the cells are defined to be 'linked' when clicked as follows:
strHTML += ' <td align="left" width=20 nowrap bgcolor="#000000" class="linksmenu" ' +
((nMenuItemStart > 0) ?
'onmouseover="this.style.background=\'#003366\';menuDescription.innerHTML=\'more menu options...\';" ' +
'onmouseout="this.style.background=\'#000000\';menuDescription.innerHTML=\'' + menuDescriptionDefault + '\'" ' +
'onclick="SetCookie(\'MenuItemStart\', ' + (nMenuItemStart - 1) + '); DisplayMenuItems();" style="CURSOR: hand"> ' : '') +
// '<span style="filter:glow(color=#336699, Strength=2);width:1">' +
((nMenuItemStart > 0) ? '<<' : '__') + '</span></td>';
Table data links work wonderful in IE but not in NS. Does it not support table data links?
03-18-2003, 06:54 PM
Netscape 4 doesn't support mouse events for table structures: onmouseover, onclick, etc. I think it limits mouse events to anchors <a> and images <img>, maybe a few other things.
03-18-2003, 07:06 PM
Thanks. It's actually NS 6 or 7. More info though, I moved (not removed) an absolute positioned layer that was 'close' (within 100 pixels or so) to the table cells in question and once the layer was out of the way it started working. Now I have two follow-up questions:
1. The mouse pointer statement (style="CURSOR: hand") doesn't work in NS 6 and 7
2. Why does a layer not directly over the cell affect it?
03-18-2003, 07:22 PM
Just to clarify - contrary to popular belief, netscape 4 supports most event handlers on most elements, it's just that most of them are not natively handled - you have to set up event listeners yourself. But that's old history.
1 - because "hand" is proprietary syntax; the correct value is "pointer". But ie5 doesn't understand that, so to get it to work for all you need use both declarations; in this order:
2 - er ... come again?
03-18-2003, 07:39 PM
1. thanks! so am I correct intranslating this as use a pointer (if you have it) then use a hand - sort of like a font listing?
2. sorry for the unclear statement. The on??? functions for my cells are being affected by a layer absolutely positioned 'near' the table - not over it. I move my mouse over the cell and get nothing, but if I move that layer way out of the way I get no problem. Any ideas?
03-18-2003, 08:02 PM
1 - not quite; a font-esque listing would be
but that won't work right. You have to do two separate declarations:
2 - check the positioned div doesn't have scope you can't see; for eg - a div typically flows all the way from x to the right edge of the page, unless you set an explicit width
03-18-2003, 09:52 PM
1. sorry to be thickheaded but what does the browser translate to? I mean, does NS read the first one and IE the second? how does it know? What's the price of tea in china? :-> THANKS!
2. I could see that impacting it if I was using the width of the div in the calculation but I'm not. It is calculating correctly and all I am setting is the left-most point - in that scenario, should the width matter?
03-20-2003, 01:31 AM
not necessarily, it depends on where it is; it's just that it sounds from your description like the DIV is covering the TD, and therefore preventing the TD event from happening.
Maybe you could a link to a page where this happening.
03-21-2003, 03:00 AM
Temporarily add a colored border to the div and it will reveal if its padding or margin overlaps the table.
03-24-2003, 03:56 PM
Brothercake - OK, I placed a sample site in http://localhost/sitesdynamic/tdtest/main_test.htm.
Again, this works wonderful in IE but not in NS.
Eggman - I tried the border color thing but I couldn't get the coloring in the div (no capability???). I surrounded the div contents with a table and that is what you will see in the above link. I tried forcing a zero width on the div and then setting the table to be 100% (like I would do for a typical table) and it always stretched all the way to the right.
More: On this page, the div contains the 'test' text in the top center of the page and the broken image below it. Now, because of another problem I am having under NS (I can't get the layer centered on the page accurately) if you size your window the div will move in the X direction at some odd ratio to the page size. Not worrying about that right now, we will use that to our advantage. Size the window so the div table border covers half of the 'main' text. This is its own cell. You will notice the next cell over becomes inactive for about one cell width from the edge of the div. As you size the window to the right you will see that less is available in the active state. Thoughts?
If you do the same stuff in IE, the centering works so it is always in the same position, but more importantly, click on 'main 2' and the entire 'main' cell will become active no matter how close to the div it is.
BTW, if you are able to click on the cell it will become inactive (via cookies) as it is the current item selected. To reinstate the original, exit the browser window and reload.
03-25-2003, 07:22 PM
you linked to localhost ... I'm afraid I don't have your webserver on my computer ;) That link again ...?
03-25-2003, 07:59 PM
03-25-2003, 08:43 PM
It's because you've used an "align" attribute on the DIV, so even though it's absolutely positioned it's still part of the flow of the page, and its position values become absolute only within the constraint of center aligment.
I'm not sure whether this is correct or not; but you can see it happening - take out the onresize function and you'll see that it still moves when you resize the window.
So take out the align attribute and you'll get consistency between them.
03-25-2003, 09:25 PM
OK - YOU GET THE MEDAL TODAY!!! THANK YOU MUCHO!!!:) :) :) :thumbsup:
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.