jcobhams
jcobhams

Reputation: 824

Checking if CKEDITOR is defined or not

I use one function to call an ajax script from two different pages. The first and original page had CKEDITOR library defined and included and it work perfectly however, page 2 is like a mini version of page one and there is no ckeditor support here so i wanted a simple way of cheking if ckeditor is defined or not so i know the appropriate way to get the form data to post to my ajax script

this is my code sample but its not working...what am i missing?...am more of a php guy not js

if(CKEDITOR !== undefined) { var msg = CKEDITOR.instances['msg'].getData();} else{var msg = $("#msg").val()};

if its any good i use jquery on both pages. The if(CKEDITOR !== undefined) { var msg = CKEDITOR.instances['msg'].getData();} part works fine, the else park does not work

Upvotes: 2

Views: 4832

Answers (2)

eidsza
eidsza

Reputation: 33

if (CKEDITOR !== undefined) { ... rest of code }

Upvotes: 0

Nikos Paraskevopoulos
Nikos Paraskevopoulos

Reputation: 40296

Perhaps it would be better to write if( typeof(CKEDITOR) !== "undefined" )....

Upvotes: 15

Related Questions