Opened 9 years ago

Closed 9 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:

Description

Go to source mode paste the below content:

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

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>
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>

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??

Browser:IE11,EDGE,chrome,firefox

Change History (1)

comment:1 Changed 9 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 http://docs.ckeditor.com/#!/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