This is a migrated thread and some comments may be shown as answers.

[Solved] Calling Javascript function upon focus

3 Answers 153 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Yasser
Top achievements
Rank 1
Yasser asked on 17 Jun 2009, 11:53 AM
Hi,

i want to call my Javascript function when focus is set to RadEditor. what is the way to do that as i am unable to find event for focus in Editor control.

Thanks

3 Answers, 1 is accepted

Sort by
0
Yasser
Top achievements
Rank 1
answered on 17 Jun 2009, 12:03 PM

Hi all, i found the way, its working fine in IE but in firefox focus is calling again and again,,

any ideas??


var OnTelerikClientLoad = function(editor, args) {

            var element = document.all ? editor.get_document().body : editor.get_document();

            $telerik.addExternalHandler(element, "focus", function(e) {

                alert("focus!");

            });

            $telerik.addExternalHandler(element, "blur", function(e) {

                alert("blur!");

            });

}
0
Yasser
Top achievements
Rank 1
answered on 18 Jun 2009, 09:38 AM
hi all , the above function is not working correctly in Firefox, its working fine in IE but not in Firefox

what is the exact way to call a JavaScript function when focus is set to Rad Editor ??
0
GT
Top achievements
Rank 1
answered on 22 Jun 2009, 06:00 AM
Hi,

I was able to run your code as expected in Firefox by simply replacing the alert() function with a reference to a div element and applying to it a new border when the focus and blur events are executed, e.g.

<div id="myDIV" style="border: 1px solid red;">test</div> 
<telerik:radeditor runat="server" OnClientLoad="OnTelerikClientLoad" ID="RadEditor1"></telerik:radeditor> 
<script type="text/javascript"
var OnTelerikClientLoad = function(editor, args)  
 
    var element = document.all ? editor.get_document().body : editor.get_document(); 
 
    $telerik.addExternalHandler(element, "focus"function(e) { 
        $get("myDIV").style.border = "2px solid green"
         
 
    }); 
 
    $telerik.addExternalHandler(element, "blur"function(e) { 
 
        $get("myDIV").style.border = "3px solid blue"
 
    }); 
}  
</script> 

I hope this helps.
Tags
Editor
Asked by
Yasser
Top achievements
Rank 1
Answers by
Yasser
Top achievements
Rank 1
GT
Top achievements
Rank 1
Share this question
or