I have an onMousedown and an onMouseup eventhandler on the document that prevents default event.
Now there is a single form element (a select field) where I want to use the default action. Can I somehow call it from javascript?
Something like:
<select ... onClick="this.browserDefaultAction">
"BrowserDefaultAction" of course dosn't exist - I made it up to explain what I'm looking for.
EDIT:
To make it somewhat clearer -
I have a table representing the days (colums) and times (rows, in units of 5 min). If the user moves the mouse over the table, each cell must show the time it represents.
If the left mouse button is pressed, the times are "set" (the cell is colored blue), if the right mouse button is pressed, the times are "unset" (the cell is colored green). This must happen "on the move", i. e. without clicking on every cell separately.
As reading the status of the mouse buttons directly in the event script didn'T work well, I added this piece of code to store the mousebutton in a custom variable:
var Maustaste = 0;
function Tastendruck (Ereignis) {
if (!Ereignis)
Ereignis = window.event;
if (Ereignis.buttons)
{
if (Ereignis.buttons == 2) {Maustaste=2}
if (Ereignis.buttons == 1) {Maustaste=1}
}
}
function Tastenlos () {
Maustaste = 0;
}
document.onmousedown = Tastendruck;
document.onmouseup = Tastenlos;
It worked well so far, even without preventing the default action.
However, moving the mouse with the button pressed also marked the cells. This didn't affect the funcitionality but looked ugly and desturbing for the user. So I just added an Ereignis.preventDefault at the end of the function.
So far, so good, but there's still this select field on the same page. I tried to attach the onmouseup/down eventhandlers not to the document, but to the table or a div container with the table within, but it just didn't work.
I anyone wants to see the page or the full code, here's the adress.
EDIT:
I used the approach
test what element triggered the event and then use prevemtDefaukt() or not as appropriate
...
if (!Ereignis)
Ereignis = window.event;
if (Ereignis.target.tagName != "SELECT")
{
if (Ereignis.buttons)
It woks now.