Click to See Complete Forum and Search --> : Firefox and onblur event


ycorre
March 31st, 2009, 11:52 AM
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 :

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 :

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.