如下代码,为什么在document的ready事件中就报FCKeditorAPI未定义的错误,而下面按钮的点击事件就没有这个问题?我现在有些和FCKeditor有关的操作希望能在页面加载的时候执行,所以肯定不能等到点按钮,所以请教此问题是否能解决?或者在其他的事件中解决?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="static/js/jquery-1.4.1.js" type="text/javascript"></script></head>
<body>
<form id="form1" runat="server">
<div>
<div>
<input name="fckContent" type="hidden" id="fckContent" runat="server" />
<input type="hidden" id="fckContent___Config" value="" />
<iframe id="fckContent___Frame" name="fckContent___Frame" src="FCKeditor/editor/fckeditor.html?InstanceName=fckContent&Toolbar=cms"
width="700px" height="360px" frameborder="no" scrolling="no"></iframe>
</div>
<div>
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</div>
</div>
</form>
<script language="javascript" type="text/javascript">
// <![CDATA[
$(document).ready(function () {
var oEditor = FCKeditorAPI.GetInstance('fckContent');
var str = oEditor.GetXHTML();
alert(str);
}); function Button1_onclick() {
var oEditor = FCKeditorAPI.GetInstance('fckContent');
var str = oEditor.GetXHTML();
alert(str);
}// ]]>
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="static/js/jquery-1.4.1.js" type="text/javascript"></script></head>
<body>
<form id="form1" runat="server">
<div>
<div>
<input name="fckContent" type="hidden" id="fckContent" runat="server" />
<input type="hidden" id="fckContent___Config" value="" />
<iframe id="fckContent___Frame" name="fckContent___Frame" src="FCKeditor/editor/fckeditor.html?InstanceName=fckContent&Toolbar=cms"
width="700px" height="360px" frameborder="no" scrolling="no"></iframe>
</div>
<div>
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</div>
</div>
</form>
<script language="javascript" type="text/javascript">
// <![CDATA[
$(document).ready(function () {
var oEditor = FCKeditorAPI.GetInstance('fckContent');
var str = oEditor.GetXHTML();
alert(str);
}); function Button1_onclick() {
var oEditor = FCKeditorAPI.GetInstance('fckContent');
var str = oEditor.GetXHTML();
alert(str);
}// ]]>
</script>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货