eWebEditor Manual V11.2 : Developer Guide : Object Reference of EWEBEDITOR : Properties and Methods of EWEBEDITOR : EWEBEDITOR.ReplaceAll Method
eWebEditor Home >> eWebEditor Manual V11.2 >> Developer Guide >> Object Reference of EWEBEDITOR >> Properties and Methods of EWEBEDITOR

3.6.2.5 EWEBEDITOR.ReplaceAll Method

Functional Description:

Replace all specified <TEXTAREA> by an editor instance. The contents of the original object will be automatically assigned to the editor as the initial value. If the editor is deleted, the editorial content within the editor will return to the original object.

Method prototype:

EWEBEDITOR.ReplaceAll( ClassNameOrCallback )

Parameters Description:

Parameters

Types

Required

Explanation

ClassNameOrCallback

Variant

No

1. If it fails to set this parameter, all <TEXTAREA> will be replaced by the editor ;

2. If it sets a character string, use the style class name to replace it. If it is set as "ewebeditor", replace the following text box.

<textarea class="ewebeditor"></textarea>

3. If it is set as a callback function, this function will bring two parameters, one is the object of textarea, and the other is the object of o_Config. If the backspace is true, it will replace it, but if it is false, it won't.

Return Value:

       None

Sample Code:

Generally, this function is used in the incident of window.onload, handle it after all the textarea loads on.

Replace all the text box of <textarea>

<head>

<script type="text/javascript">

function _Onload(){

       EWEBEDITOR.ReplaceAll();

}

 

if ( window.addEventListener ){

       window.addEventListener( 'load', _Onload, false );

}else if ( window.attachEvent ){

       window.attachEvent( 'onload', _Onload );

}</script>

</head>

<body>

<textarea name="textarea1"></textarea>

<textarea name="textarea2"></textarea>

</body>

 

Replace all the text box of <textarea class="abc">

<head>

<script type="text/javascript">

function _Onload(){

       EWEBEDITOR.ReplaceAll("abc");

}

 

if ( window.addEventListener ){

       window.addEventListener( 'load', _Onload, false );

}else if ( window.attachEvent ){

       window.attachEvent( 'onload', _Onload );

}</script>

</head>

<body>

<textarea name="textarea1" class="abc"></textarea>

<textarea name="textarea2"></textarea>

</body>

 

Replace the specified text box of <TEXTAREA>, use the Callback Function, in the example, the text box name=textarea1 will be replaced.

<head>

<script type="text/javascript">

function _Callback(o_Textarea, o_Config){

       o_Config.style = "gray";

       o_Config.width = "550";

       if (o_Textarea.name=="textarea1"){

              return true;

       }else{

              return false;

       }

}

 

function _Onload(){

       EWEBEDITOR.ReplaceAll( _Callback );

}

 

if ( window.addEventListener ){

       window.addEventListener( 'load', _Onload, false );

}else if ( window.attachEvent ){

       window.attachEvent( 'onload', _Onload );

}

</script>

</head>

<body>

<textarea name="textarea1"></textarea>

<textarea name="textarea2"></textarea>

</body>