Error in setting Javascript property

Asked

Viewed 1,115 times

1

I’m using the API Sceditor and when I load the page, the following error appears:

0x800a138f - Javascript runtime error: Unable to set the indefinite or null reference '_sceditor' property

<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>
  • It may be that your script is running before loading the plugin scripts.

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'
    });
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.