J
jonathanmcdougall
I am developing a calendar on which dates can be clicked and selected.
A calendar is a table in which each day is a cell. Each cell has a
unique id.
By left-clicking on a date, it gets selected (with a blue background).
By then shift-left-clicking on another date, the range between the
first and second dates gets selected. This is a behavior commonly found
on GUI widgets. Therefore, I need to cancel the onMouseDown event so
the browser does not select the text by responding to shift-left-click
event. If I don't, the date cells get selected, but so is the text.
Simply returning false from the event handler works for Firefox but
doesn't for Internet Explorer 6. I tried setting cancelBubble to true
and returnValue to false to no avail. However, displaying an alert()
window prevents the selection, though I do not know if this is an
artifact from the window losing the focus. A post in this group
(http://tinyurl.com/g5au4) stated that "the alert is necessary for the
'return false' to properly work".
Setting a timer from onMouseDown to clear the selection does work, but
the selection is visible on screen for a fraction of second before
getting cleared. That's not a viable solution for me.
How do I prevent Internet Explorer (5.5+ if possible) from selecting
text when the user left-clicks with the shift key pressed?
Thank you,
Jonathan
A calendar is a table in which each day is a cell. Each cell has a
unique id.
By left-clicking on a date, it gets selected (with a blue background).
By then shift-left-clicking on another date, the range between the
first and second dates gets selected. This is a behavior commonly found
on GUI widgets. Therefore, I need to cancel the onMouseDown event so
the browser does not select the text by responding to shift-left-click
event. If I don't, the date cells get selected, but so is the text.
Simply returning false from the event handler works for Firefox but
doesn't for Internet Explorer 6. I tried setting cancelBubble to true
and returnValue to false to no avail. However, displaying an alert()
window prevents the selection, though I do not know if this is an
artifact from the window losing the focus. A post in this group
(http://tinyurl.com/g5au4) stated that "the alert is necessary for the
'return false' to properly work".
Setting a timer from onMouseDown to clear the selection does work, but
the selection is visible on screen for a fraction of second before
getting cleared. That's not a viable solution for me.
How do I prevent Internet Explorer (5.5+ if possible) from selecting
text when the user left-clicks with the shift key pressed?
Thank you,
Jonathan