【发布时间】:2013-04-16 14:08:00
【问题描述】:
情况: 在 jQuery 对话框中调用 CKEDITOR(这里有很多挑战)。 我的具体问题是,当我测试是否存在 CKEDITOR 实例时,总是会抛出错误。
经过测试的浏览器:Firefox 21、IE 9、Safari 5.1.7
错误:Error: TypeError: CKEDITOR.instance is undefined
所有这些测试 CKEDITOR 实例的方法总是抛出一个 javascript 错误:
if(!CKEDITOR.instance['editor']){
if(CKEDITOR.instance['editor']){
if(!typeof CKEDITOR.instance['editor'] == "undefined"){
if(!typeof(CKEDITOR.instance['editor']) == "undefined"){
if(typeof CKEDITOR.instance['editor'] != "undefined"){
if(typeof CKEDITOR.instance['editor'] !== "undefined"){
if(typeof CKEDITOR.instance['editor'] === "undefined"){
当然,在发表这篇文章之前,我浏览了 StackOverflow。我已经尝试过 StackOverflow 上建议的“typeof”和“undefined”的所有组合。
如果在测试实例存在时出错,我该如何测试对象实例的存在?一个难题!
【问题讨论】:
-
if(typeof CKEDITOR.instance === "undefined"){
标签: javascript jquery ckeditor typeof