Firefox and onblur event
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Firefox and onblur event

  1. #1
    Join Date
    Mar 2009
    Posts
    2

    Firefox and onblur event

    Hello,

    I have an ASP.Net application where all my TextBox components contain the "onblur" and "onfocus" events.

    The principle:
    - I'd like to allow the text selection in the control (when focusing)
    - I'd like to disable the text selection of my page when outside the control (on onblur)

    So, I have this code on the onfocus event :

    Code:
    function SetBodyDragOn(o)
    {
      document.body.onselectstart = new Function("return true;");
      document.body.ondragstart = new Function("return true;");
      document.body.onselect = new Function("return true;");
     
      // Set an edit design class on the textbox control
      if (o)
        o.className = "InputEditingOn";
    }
    And this one on the onblur event :

    Code:
    function SetBodyDragOff(event, o)
    {
      if (typeof event.preventDefault != 'undefined') event.preventDefault();
      document.body.onselectstart = new Function(" {event.returnValue=false; try { event.stopPropagation(); event.preventDefault() } catch (ex) {alert(ex.message)} return false; } ");
      document.body.ondragstart = new Function(" {event.returnValue=false; try { event.stopPropagation(); event.preventDefault() } catch (ex) {alert(ex.message)} return false; } ");
      document.body.onselect = new Function(" {event.returnValue=false; try { event.stopPropagation(); event.preventDefault() } catch (ex) {alert(ex.message)} return false; } ");
     
      // Set a standard design class on the textbox control
      if (o)
        o.className = "InputEditingOff";
    }
    With all the browsers (even Firefox), it works fine during one moment.
    After a certain time of using, on Firefox, the onblur is not fired.
    The cursor stays in the control.

    Why this behavior?
    Why it works a certain time and not after (memory problem?)
    To soluce the problem, I have to reboot my Firefox.

    Thanks in advance,
    Yannis.
    Last edited by PeejAvery; March 31st, 2009 at 11:42 AM. Reason: Added code tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center