We are trying to use the word count function in FCK and it works fine in Opera, Firefox and IE. Safari and Chrome throw this error:
Can't find variable: FCKeditorAPI
Here is the script:
<script type="text/javascript">
countChars = function(text,button,synopsis,rating,orthodoxy,readinglevel) {
////////////////////////////// begin
// Get the length of the text including html tags
var oBody = text;
var chars = (oBody.length);
var value = '';
var errorvalue = '';
var ratingerror = '';
var success = '';
// Set the rating error for rating fields not changed.
if (rating == true){
var ratingerror = 1
};
if (orthodoxy == true){
var ratingerror = 1
};
if (readinglevel == true){
var ratingerror = 1
};
// Excluding html tags
var start_tag = /<.*?>/g;
var end_tag = /<\/.*?>/g;
var nohtml = oBody.replace(end_tag,'');
nohtml = nohtml.replace(start_tag,'');
var temp_arr = nohtml.split(/[^\b\w+\b]/g);
var arr = new Array(); arr_index = 0;
for(i = 0; i < temp_arr.length; i++){
if(temp_arr[i] != ""){
arr[arr_index] = temp_arr[i];
arr_index++;
}
};
//Set alert text values
if (synopsis == '') {
var value = 'Please enter a synopsis.\n\n'
};
if (ratingerror == 1) {
errorvalue = 'Please rate this item.\n\n'
};
if (synopsis != '') {
if (ratingerror != 1) {
if (arr.length >= 300) {
var success = 'You may now submit the review.'
}
}
}
//Enable submit button
if (arr.length >= 300) {
if (synopsis != '') {
if (ratingerror != 1) {
button.disabled = false
}
};
};
//Display alert message
if (success == '') {
alert(value + errorvalue + 'You currently have ' + arr.length + ' words in your review.\nTo submit a review, there must be at least\n300 words in your review.')
}
else {
alert('You currently have ' + arr.length + ' words in your review.\n\nYou may now submit.')
};
////////////////////////////// end
}
</script>
Can't find variable: FCKeditorAPI
Here is the script:
<script type="text/javascript">
countChars = function(text,button,synopsis,rating,orthodoxy,readinglevel) {
////////////////////////////// begin
// Get the length of the text including html tags
var oBody = text;
var chars = (oBody.length);
var value = '';
var errorvalue = '';
var ratingerror = '';
var success = '';
// Set the rating error for rating fields not changed.
if (rating == true){
var ratingerror = 1
};
if (orthodoxy == true){
var ratingerror = 1
};
if (readinglevel == true){
var ratingerror = 1
};
// Excluding html tags
var start_tag = /<.*?>/g;
var end_tag = /<\/.*?>/g;
var nohtml = oBody.replace(end_tag,'');
nohtml = nohtml.replace(start_tag,'');
var temp_arr = nohtml.split(/[^\b\w+\b]/g);
var arr = new Array(); arr_index = 0;
for(i = 0; i < temp_arr.length; i++){
if(temp_arr[i] != ""){
arr[arr_index] = temp_arr[i];
arr_index++;
}
};
//Set alert text values
if (synopsis == '') {
var value = 'Please enter a synopsis.\n\n'
};
if (ratingerror == 1) {
errorvalue = 'Please rate this item.\n\n'
};
if (synopsis != '') {
if (ratingerror != 1) {
if (arr.length >= 300) {
var success = 'You may now submit the review.'
}
}
}
//Enable submit button
if (arr.length >= 300) {
if (synopsis != '') {
if (ratingerror != 1) {
button.disabled = false
}
};
};
//Display alert message
if (success == '') {
alert(value + errorvalue + 'You currently have ' + arr.length + ' words in your review.\nTo submit a review, there must be at least\n300 words in your review.')
}
else {
alert('You currently have ' + arr.length + ' words in your review.\n\nYou may now submit.')
};
////////////////////////////// end
}
</script>
Re: Safari and word count
Re: Safari and word count
Re: Safari and word count
Re: Safari and word count