Hello,
I have searched in google, but I didn't find the answer.
I want to creat something like that using javaScript:

<input type="text" onfocus="this.select();lcs(this);" onclick="event.cancelBubble=true;this.select();lcs(this);"  />

here is my try, which works fine in Firefox but the events are not working in IE.

var parent  = document.getElementById(parentID);
      newInputFrom         = document.createElement('input');
      newInputFrom.type    = 'text';
      newInputFrom.setAttribute("onfocus","this.select();lcs(this);");
      newInputFrom.setAttribute("onclick","event.cancelBubble=true;this.select();lcs(this);");

Any idea?

hi,
I ve found a solution for the ie

newInputFrom.onfocus = function () { this.select(); lcs(this); };
newInputFrom.onclick = function () { event.cancelBubble=true; this.select(); lcs(this); };

but it's not working in Firefox:icon_neutral:
to get the desired result in both ie and ff :

if( document.all){
        newInputFrom.onfocus = function () { this.select(); lcs(this); };
        newInputFrom.onclick = function () { event.cancelBubble=true; this.select(); lcs(this); };
      }
      else{
        newInputFrom.setAttribute("onfocus","this.select();lcs(this);");
        newInputFrom.setAttribute("onclick","event.cancelBubble=true;this.select();lcs(this);");
      }

do you have any better solution?

some time we need to write the code for both IE and FF its not a problem....carry on with this code.

This article has been dead for over six months. Start a new discussion instead.