Javascript to set focus

Last post 08-27-2010, 10:23 AM by Eric. 1 replies.
Sort Posts: Previous Next
  •  08-27-2010, 3:12 AM 63690

    Javascript to set focus

    I have a javascript to check the input item in the editor, if there is empty, it would set focus on the editor
    I tried to use
     
    var txt = document.getElementById('<%= Editor1.ClientID%>');
    txt.focus();
     
    or
     
    document.Editor1.focus();
     
    both are not success
  •  08-27-2010, 10:23 AM 63695 in reply to 63690

    Re: Javascript to set focus

    Dear surrounding,
     
    Please try the following code:
    function setFocus()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('<%=editor.ClientID%>');
        
        editor1.FocusDocument();
       }
    You can refer to JavaScript-API.asp which can be found in download package.
     
    thanks for asking
View as RSS news feed in XML