JavaScript property definition error

0

I'm using the SCEditor API and when I load the page, the following error appears:

0x800a138f - JavaScript runtime error: Can not set the '_sceditor' property of undefined or null reference

<link rel="stylesheet" href="minified/themes/default.min.css" />
<script src="minified/sceditor.min.js"></script>
<script src="minified/formats/bbcode.js"></script>
<script src="minified/formats/xhtml.js"></script>
<script>
 var textarea = document.getElementById('example');
 sceditor.create(textarea, {
 format: 'xhtml',
 style: 'minified/themes/content/default.min.css'
});
</script>
    
asked by anonymous 05.01.2018 / 17:12

1 answer

1

Use DOMContentLoaded , to check when the document is loaded, like this:

document.addEventListener("DOMContentLoaded", function () {
    var textarea = document.getElementById('example');
    sceditor.create(textarea, {
        format: 'xhtml',
        style: 'minified/themes/content/default.min.css'
    });
});
    
05.01.2018 / 17:28