(New page: == Frequently Asked Questions : JavaScript == * How do I apply a tabindex on the FCKeditor? * [[#changeContentHow do I dynamically change the content in the editor with Java...) |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | == Frequently Asked Questions : JavaScript == | + | __NOTOC__ |
+ | == Frequently Asked Questions : JavaScript == | ||
− | * [[# | + | *[[#changeContent|How do I dynamically change the content in the editor with JavaScript?]] |
− | + | *[[#javascriptParent|How do I call a javascript function on the page containing the editor from a plugin?]] | |
− | * [[# | + | *[[FCKeditor 2.x/Developers Guide/FAQ/JavaScirpt/OnkeyEvent|How do I capture an onkey event within FCKeditor?]] |
− | |||
− | * [[ | ||
− | === <span id=" | + | === <span id="changeContent">How do I dynamically change the content in the editor with JavaScript?</span> === |
+ | |||
+ | Just use the FCKeditor JavaScript API: | ||
+ | <pre>function getEditorValue( instanceName ) | ||
+ | { | ||
+ | // Get the editor instance that we want to interact with. | ||
+ | var oEditor = FCKeditorAPI.GetInstance( instanceName ) ; | ||
+ | |||
+ | // Get the editor contents as XHTML. | ||
+ | return oEditor.GetXHTML( true ) ; // "true" means you want it formatted. | ||
+ | } | ||
+ | |||
+ | function setEditorValue( instanceName, text ) | ||
+ | { | ||
+ | // Get the editor instance that we want to interact with. | ||
+ | var oEditor = FCKeditorAPI.GetInstance( instanceName ) ; | ||
+ | |||
+ | // Set the editor contents. | ||
+ | oEditor.SetHTML( text ) ; | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | === <span id="javascriptParent">How do I call a javascript function on the page containing the editor from a plugin?</span> === | ||
+ | |||
+ | If you want to call a function contained in the page that instantiates the FCKeditor, you will need to add "parent." to the function name in the plugin.js. | ||
+ | |||
+ | Let's say that in fun.html I have a function named "SetSelected". If I were writing a plugin for use on the fun.html page, and I wanted it to call the !SetSelected() function from plugin.js, I would simply have to add parent to it. | ||
+ | |||
+ | E.g. '''parent'''.''SetSelected();'' Sometimes you may have nested the editor another level; just add another parent like: ''parent.parent.SetSelected();'' |
Latest revision as of 13:27, 29 May 2008
Frequently Asked Questions : JavaScript
- How do I dynamically change the content in the editor with JavaScript?
- How do I call a javascript function on the page containing the editor from a plugin?
- How do I capture an onkey event within FCKeditor?
How do I dynamically change the content in the editor with JavaScript?
Just use the FCKeditor JavaScript API:
function getEditorValue( instanceName ) { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance( instanceName ) ; // Get the editor contents as XHTML. return oEditor.GetXHTML( true ) ; // "true" means you want it formatted. } function setEditorValue( instanceName, text ) { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance( instanceName ) ; // Set the editor contents. oEditor.SetHTML( text ) ; }
How do I call a javascript function on the page containing the editor from a plugin?
If you want to call a function contained in the page that instantiates the FCKeditor, you will need to add "parent." to the function name in the plugin.js.
Let's say that in fun.html I have a function named "SetSelected". If I were writing a plugin for use on the fun.html page, and I wanted it to call the !SetSelected() function from plugin.js, I would simply have to add parent to it.
E.g. parent.SetSelected(); Sometimes you may have nested the editor another level; just add another parent like: parent.parent.SetSelected();