On Aug 28, 1:54 pm, Martijn <[email protected]> wrote:
> On Thu, Aug 28, 2008 at 12:37 PM, <[email protected]> wrote:
> > On Aug 20, 3:37 pm, Martijn <[email protected]> wrote:
> >> On Wed, Aug 20, 2008 at 1:28 PM, <[email protected]> wrote:
> >> > Hi all!
> >> > I've got a problem with preventDefault() on some FF widgets. Please
> >> > see the example below (works in Opera 9.5). The checkbox is ok but
> >> > there is no way to prevent the default action on SELECT element. I've
> >> > tried even with document.addEventListener in capture phase. And still
> >> > nothing. Any hints, workarounds?
>
> >> No hint or workaround from me, but this seems to behttps://bugzilla.mozilla.org/show_bug.cgi?id=291082
>
> >> Perhaps you could do something like this as a workaround?
> >> event.target.blur();
> >> setTimeout(function(aEl) {aEl.focus()}, 0, event.target);
>
> >> Regards,
> >> Martijn
>
> >> > <html>
> >> > <head>
> >> > <script type="text/javascript">
> >> > var KEY_LEFT = 0x25;
> >> > var KEY_RIGHT = 0x27;
>
> >> > function elem_onKey(event)
> >> > {
> >> > switch (event.keyCode){
> >> > case KEY_LEFT:
> >> > //dump("left\n");
> >> > break;
> >> > case KEY_RIGHT:
> >> > //dump("right\n");
> >> > break;
> >> > default:
> >> > return true;//propagate
> >> > }
> >> > event.preventDefault();
> >> > event.stopPropagation();
> >> > return false;//just consume the event when it matches one of defined
> >> > keys
> >> > };
>
> >> > </script>
> >> > </head>
> >> > <body>
> >> > <select onkeydown="elem_onKey(event);"
> >> > onkeyup="elem_onKey(event);"
> >> > onkeypress="elem_onKey(event);">
> >> > <option> a </option>
> >> > <option> b </option>
> >> > <option> c </option>
> >> > <option> d </option>
> >> > </select>
> >> > <br>
> >> > <form>
> >> > <input type="checkbox" onclick="event.preventDefault();"
> >> > onmouseover="event.preventDefault();"
> >> > onmousedown="event.preventDefault();"/>
> >> > <label for="checkbox">Checkbox</label>
> >> > </form>
> >> > </body>
> >> > </html>
> >> > _______________________________________________
> >> > dev-tech-dom mailing list
> >> > [email protected]
> >> >https://lists.mozilla.org/listinfo/dev-tech-dom
>
> >> --
> >> Martijn Wargers - Help Mozilla!http://weblogs.mozillazine.org/qa/http://wiki.mozilla.org/Mozilla_QA_...
> >> irc://irc.mozilla.org/qa - /nick mw22
>
> > Hello.I would like to keep the old value(it depends on me when this
> > will happen) when somebody uses a select element.
> > I mean i change the select element from value 1 to 2 but because of
> > some reasons i would like to return to 1.
> > How can i do that please?
>
> Use the onchange event handler perhaps?
>
> > I have tried a lot of things.
> > Is there a solution that works both in FF and IE ?
> > btw what is aEl that you mentioned earlier?
> > thanks!
>
> aEl is just a variable that gets passed to the function, from outside
> it, that I then can use inside the function.
>
> Regards,
> Martijn
>
> > _______________________________________________
> > dev-tech-dom mailing list
> > [email protected]
> >https://lists.mozilla.org/listinfo/dev-tech-dom
>
> --
> Martijn Wargers - Help Mozilla!http://weblogs.mozillazine.org/qa/http://wiki.mozilla.org/Mozilla_QA_Community
> irc://irc.mozilla.org/qa - /nick mw22
thank you for replying.
well i found the solution,but the fact is that it doesn't work if by
example i just return false.the new 'option' is selected.i did it
using the onfocus,saving the previous value etc.
thanks about the variable ;)
thanks again!
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.