Opened 8 years ago

Closed 8 years ago

#14527 closed Bug (invalid)

content inside <script> tag is not showing up in the editor

Reported by: Sibasish palo Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:


Go to source mode paste the below content:

<!DOCTYPE html>
<p id="demo"></p>
document.getElementById("demo").innerHTML = "Hello JavaScript!";

switching out from source mode will strip everything from the editor.
added the below configuration to the config.js to disable advance filtering

config.allowedContent = true;

after adding the above configuration <script> is not stripping and the content became as follows:

<p id="demo">&nbsp;</p>
document.getElementById("demo").innerHTML = "Hello JavaScript!";

But switching out from source mode doesn't showing any content and gives a blank editor where as it should display "Hello JavaScript!" in the editor.

Note that instead of assigning the value "Hello JavaScript!" to <p> tag its adding "&nbsp;"

is there any configuration that i can activate so that the content will show up in the editor or else is there any way to show up the java script content in the editor??


Change History (1)

comment:1 Changed 8 years ago by Jakub Ś

Resolution: invalid
Status: newclosed
Version: 4.5.7

Script execution is blocked inside CKEditor content area. You can't insert scripts like that and hope they get executed.

You can protect them with!/api/CKEDITOR.config-cfg-protectedSource and see how they are executed in preview mode.

You can use below configuration for CKEditor instance:

var editor = CKEDITOR.replace( 'editor1', {
protectedSource : [/<script[\s\S]*?<\/script>/gi ], 
extraAllowedContent : 'p[id]'
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy