在window.onload中调用也不成么?
看到楼主在fckeditor上花了N多分了,都有点不敢用了,呵呵
看到楼主在fckeditor上花了N多分了,都有点不敢用了,呵呵
解决方案 »
- js实现一种加密算法问题
- 大家帮我看看问题出在哪儿了,实在是不知道怎么办了
- 在线音乐链接
- 在下面代码上修改。怎么在图片下加个格导航【1】【2】【3】【4】【5】?解决加分
- 求教 EXT GRID 禁用 隱藏列
- 文本框的离开事件(在线等)
- 第一次加载iFrame可以自适应高度,但第二次处理时确不行。
- 本人刚学JS第一天上班的问题快救我
- 如何得到对象名?
- 如何让flash文件高度和宽度为网页的高度和宽度?
- 一直被一个问题困扰:当div的display为none时,如何获取它的实际宽度??? offsetWidth此时为0,而style中的width也不准确(100%,被撑大)
- 动态添加的embed SVG元素如何获得其svgdoc?
可能是放的位置的问题。把 InitializeAPI() ; 放到页面最下面试试
<html>
....
<body>
....
<!--把调用放到这里试试-->
</body>
</html>
我在这句上面写了一个延时什么的都不行!555taobao baidu都用fck的啊!可能是我js水平太差了啊。唉
从现象上看象是画面没有加载完成。
是不是父画面的东西比较多呀。
调用其它窗口的时候判断一下 readyState == "complete";另外,失败的时候,
楼主至少应该定位到失败的语句。在代码中加入几条alert();
很容易就定位到出错的语句了。
然后再找问题就容易了。
很容易就定位到出错的语句了。
看看是不是其中的哪一个没有加载完造成的
;
FCKeditorAPI = A.FCKeditorAPI;
FCKeditorAPI.__Instances = FCKeditorAPI.Instances;就是FCKeditorAPI is undefined
啊!但不知道怎么解决啊
这样不可以?
没怎么用过FCK也不大了解,如果楼上的方法还是不行,这样子再试试:
(function () {
if(A.FCKeditorAPI)InitializeAPI();
else setTimeout(arguments.callee, 1000);
})();
在alert之前和之后 alert那个方法看看
反正先调试看看 alert之前和之后有哪些地方不一样
在fckeditor.html这个文件加中就有调用这个方法的window.onload = function()
{
InitializeAPI() ; if ( FCKBrowserInfo.IsIE )
FCK_PreloadImages() ;
else
LoadToolbarSetup() ;
}看到没,就是跟我说得那调用方法是一样的
(function(){
if(InitializeAPI)
InitializeAPI();
else
setTimeout(arguments.callee, 50)
})()
(function(){
if(InitializeAPI)
InitializeAPI();
else
setTimeout(arguments.callee, 50)
})()
scriptObj.onreadystatechange = function(){
var state = scriptObj.readyState;
if (state == "loaded" || state == "complete") {
// 加载完毕
}
};或者将InitializeAPI放在body之后试试<html>
...
<body>
...
</body>
<script>
InitializeAPI();
</script>
</html>
if(InitializeAPI)
InitializeAPI();
else
setTimeout(arguments.callee, 50)
})()
最感谢就是你了!帮助了我很多啊!
可是这样解决不了fck把这段代码var B = 'window.FCKeditorAPI = {Version : "2.6.2",VersionBuild : "19417",Instances : new Object(),GetInstance : function( name ){return this.Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}';
先当成一个变量!然后当一个js输出在在页面上!然后在用里面的方法!
我曾经尝试把这段代码放到一个js里面然后直接在页面上引用这个js还是失败!
而且就只有ff2.xxx17以上版本有问题!ie和以下版本都没问题!我也只是感觉是加载的问题不知道实际是是什么!
我现在唯一的思路就是想知道有什么功能可以跟alert效果一样但是!不弹出窗口
我就是在 InitializeAPI() ; 前面alert就可以初始化,fck编辑区也显示正常
如果去掉alert就会提示FCKeditorAPI is undefined,fck编辑区就就显示不出来然后下面就是InitializeAPI() 的全部内容啊!
function InitializeAPI()
{
var A = window.parent;
if ( ! (FCKeditorAPI = A.FCKeditorAPI))
{
var B = 'window.FCKeditorAPI = {Version : "2.6.2",VersionBuild : "19417",Instances : new Object(),GetInstance : function( name ){return this.Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}';
if (A.execScript) A.execScript(B, 'JavaScript');
else
{
if (FCKBrowserInfo.IsGecko10)
{
eval.call(A, B);
}
else if(FCKBrowserInfo.IsAIR)
{
FCKAdobeAIR.FCKeditorAPI_Evaluate(A, B);
}
else if (FCKBrowserInfo.IsSafari || FCKBrowserInfo.IsGecko19)
{
var C = A.document;
var D = C.createElement('script');
D.appendChild(C.createTextNode(B));
C.documentElement.appendChild(D);
}
else A.eval(B);
}
;
FCKeditorAPI = A.FCKeditorAPI;
FCKeditorAPI.__Instances = FCKeditorAPI.Instances;
}
;
FCKeditorAPI.Instances[FCK.Name] = FCK;
}
这样判断肯定不行了,你不是InitializeAPI undefined,而是FCKeditorAPI,如果要用这种方法应该是
(function () {
if(A.FCKeditorAPI)InitializeAPI();
else setTimeout(arguments.callee, 1000);
})();
就是这样测试的啊!下面这样也测试过不行!哎
while(true)
{
if(A.FCKeditorAPI)
{
break;
}
}
{
if(A.FCKeditorAPI)
{
break;
}
}
这样当然不行,死在一个循环里了,又不是两个线程,楼主的这个东西我不清楚,但可以考虑这样的方法试一下:
var oTid = null;
function vid()
{
if(!A.FCKeditorAPI)
return;
clearInterval(oTid);
you_init();
}
oTid setInterval(vid,1000);
{
if(A.FCKeditorAPI)
{
break;
}
}
这样当然不行,死在一个循环里了,又不是两个线程,楼主的这个东西我不清楚,但可以考虑这样的方法试一下:
var oTid = null;
function vid()
{
if(!A.FCKeditorAPI)
return;
clearInterval(oTid);
you_init();
}
oTid = setInterval(vid,1000);
function InitializeAPI()
{
var A = window.parent;
if(!A.FCKeditorAPI){
return window.setTimeout(function(){InitializeAPI();},100);
}
if ( ! (FCKeditorAPI = A.FCKeditorAPI))
{
var B = 'window.FCKeditorAPI = {Version : "2.6.2",VersionBuild : "19417",Instances : new Object(),GetInstance : function( name ){return this.Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}';
if (A.execScript) A.execScript(B, 'JavaScript');
else
{
if (FCKBrowserInfo.IsGecko10)
{
eval.call(A, B);
}
else if(FCKBrowserInfo.IsAIR)
{
FCKAdobeAIR.FCKeditorAPI_Evaluate(A, B);
}
else if (FCKBrowserInfo.IsSafari || FCKBrowserInfo.IsGecko19)
{
var C = A.document;
var D = C.createElement('script');
D.appendChild(C.createTextNode(B));
C.documentElement.appendChild(D);
}
else A.eval(B);
}
;
FCKeditorAPI = A.FCKeditorAPI;
FCKeditorAPI.__Instances = FCKeditorAPI.Instances;
}
;
FCKeditorAPI.Instances[FCK.Name] = FCK;
}
问题还没有解决呀!!?
楼主在父窗口的 onload 事件中调用一下这个InitializeAPI函数试试.
调用的时候判断一下iframe的readyState.
scriptObj.onreadystatechange = function(){
var state = scriptObj.readyState;
if (state == "loaded" || state == "complete") {
// 加载完毕
}
};
var ParentFormIst,ParentFormName,ParentFormItem;//是否能获取到父框架/父框架表单名/父框架表单项目
var FormCnt,UrlHeight,AvaiHeight,NowMode=0;//NowMode:1设计 2代码 3拆分 4预览
var View_1,View_2,View_3,View_4,View_5;
var MSIE=window.attachEvent?true:false;
//
document.oncontextmenu=function(evt){return false;}
function MyPE_Initializtion(v1,v2,v3,h,ist,formname,formitem){//初始化
if(MSIE){
EditIDE=window.frames[v1];EditIDE.document.designMode="on";EditIDE.document.oncontextmenu=function(evt){return false;}
EditIDD=window.frames[v2];EditIDD.document.designMode="on";EditIDD.document.oncontextmenu=function(evt){return false;}
EditIDP=window.frames[v3];
}
else{
EditIDE=document.getElementById(v1);EditIDE.contentDocument.designMode="on";
EditIDD=document.getElementById(v2);EditIDD.contentDocument.designMode="on";
EditIDP=document.getElementById(v3);
}
window.onload=function(evt){
ParentFormName=window.parent.document.forms[formname];
if(typeof(ParentFormName)=="object"){ParentFormIst=true;ParentFormItem=ParentFormName.elements[formitem];}
else{ParentFormIst=false;alert("提示:编辑器无法取得内容,建议您联系管理员!");return false;}
if(MSIE){}//EditIDE.attachEvent("onblur",MyPE_OnBlur1);EditIDD.attachEvent("onblur",MyPE_OnBlur2);
else{EditIDE.contentWindow.addEventListener("blur",MyPE_OnBlur1,false);EditIDD.contentWindow.addEventListener("blur",MyPE_OnBlur2,false);}
MyPE_IniTableMenu(1);MyPE_IniTableMenu(2);MyPE_IniTableMenu(3);
FormCnt=document.mypeform.cnt;
UrlHeight=h;
View_1=document.getElementById("div1");View_1.style.display="";
View_2=document.getElementById("div2");View_2.style.display="";
AvaiHeight=UrlHeight-View_1.offsetHeight-View_2.offsetHeight-4;//未知原因-4才正好布局满
View_3=document.getElementById("div3");
View_4=document.getElementById("div4");
View_5=document.getElementById("div5");
MyPE_SetMode(1);
if(ist==1){
var str=ParentFormItem.value;
FormCnt.value=str;
if(MSIE){EditIDD.document.body.innerHTML=str;}
else{EditIDD.contentDocument.body.innerHTML=str;}
}
}
}
iframe中的,后来我的解决方案是
var obj;
if(FCKeditorAPI)
obj=FCKeditorAPI.GetInstance("<%= this.FCKeditor1.ClientID %>");
else
obj=document.getElementById("<%= this.FCKeditor1.ClientID %>");
我猜是页面初始化的时候,FCKeditorAPI还没有初始化,所以会报这错.你前面加个alert(),就相当于暂停了一下,但是此时iframe中的函数继续执行,所以就能取到.不加就不能取到.
iframe中的,后来我的解决方案是
var obj;
if(FCKeditorAPI)
obj=FCKeditorAPI.GetInstance("<%= this.FCKeditor1.ClientID %>");
else
obj=document.getElementById("<%= this.FCKeditor1.ClientID %>");
我猜是页面初始化的时候,FCKeditorAPI还没有初始化,所以会报这错.你前面加个alert(),就相当于暂停了一下,但是此时iframe中的函数继续执行,所以就能取到.不加就不能取到.
改了没用啊死循环了!
程序结构如下!
xxx.html引用1.js,我在1.js中显示FCK编辑器
1.js调用,2.js的viewFCK方法.该方法会调用oFCKeditor.Create() ;
这个方法是FCK初始化的方法!这个方法会去fckeditor.html执行
window.onload = function()
{
.....
InitializeAPI() ;
.......
}
我就是InitializeAPI这个方法过不去!
总是提示我FCKeditorAPI is undefined
ff2.16以下和ie6,7都没问题只有ff3有这个问题!
但是如果把1.js增加一个alert修改成下面的就没问题了不知道为什么啊
document.write("<td>");
alert("");
viewFCK("......");
document.write("<td>");
一.1.js
document.write("<td>");
viewFCK("......");
document.write("<td>");
二.2.js
function viewFCK(){
..................
oFCKeditor.Create() ;
}
三.fckeditor.html
window.onload = function()
{
.....
InitializeAPI() ;
.......
}
四.fckeditorcode_gecko.js
function InitializeAPI()
{
var A = window.parent;
if(!A.FCKeditorAPI){
return window.setTimeout(function(){InitializeAPI();},100);
}
if ( ! (FCKeditorAPI = A.FCKeditorAPI))
{
var B = 'window.FCKeditorAPI = {Version : "2.6.2",VersionBuild : "19417",Instances : new Object(),GetInstance : function( name ){return this.Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}';
if (A.execScript) A.execScript(B, 'JavaScript');
else
{
if (FCKBrowserInfo.IsGecko10)
{
eval.call(A, B);
}
else if(FCKBrowserInfo.IsAIR)
{
FCKAdobeAIR.FCKeditorAPI_Evaluate(A, B);
}
else if (FCKBrowserInfo.IsSafari || FCKBrowserInfo.IsGecko19)
{
var C = A.document;
var D = C.createElement('script');
D.appendChild(C.createTextNode(B));
C.documentElement.appendChild(D);
}
else A.eval(B);
}
;
FCKeditorAPI = A.FCKeditorAPI;
FCKeditorAPI.__Instances = FCKeditorAPI.Instances;
}
;
FCKeditorAPI.Instances[FCK.Name] = FCK;
}
xxx.html引用1.js,我在1.js中显示FCK编辑器
1.js调用,2.js的viewFCK方法.该方法会调用oFCKeditor.Create() ;
这个方法是FCK初始化的方法!这个方法会去fckeditor.html执行
window.onload = function()
{
.....
InitializeAPI() ;
.......
}
我就是InitializeAPI这个方法过不去!
总是提示我FCKeditorAPI is undefined
ff2.16以下和ie6,7都没问题只有ff3有这个问题!
但是如果把1.js增加一个alert修改成下面的就没问题了不知道为什么啊
document.write("<td>");
alert("");
viewFCK("......");
document.write("<td>");
一.1.js
document.write("<td>");
viewFCK("......");
document.write("<td>");
二.2.js
function viewFCK(){
..................
oFCKeditor.Create() ;
}
三.fckeditor.html
window.onload = function()
{
.....
InitializeAPI() ;
.......
}
四.fckeditorcode_gecko.js
function InitializeAPI()
{
var A = window.parent;
if(!A.FCKeditorAPI){
return window.setTimeout(function(){InitializeAPI();},100);
}
if ( ! (FCKeditorAPI = A.FCKeditorAPI))
{
var B = 'window.FCKeditorAPI = {Version : "2.6.2",VersionBuild : "19417",Instances : new Object(),GetInstance : function( name ){return this.Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}';
if (A.execScript) A.execScript(B, 'JavaScript');
else
{
if (FCKBrowserInfo.IsGecko10)
{
eval.call(A, B);
}
else if(FCKBrowserInfo.IsAIR)
{
FCKAdobeAIR.FCKeditorAPI_Evaluate(A, B);
}
else if (FCKBrowserInfo.IsSafari || FCKBrowserInfo.IsGecko19)
{
var C = A.document;
var D = C.createElement('script');
D.appendChild(C.createTextNode(B));
C.documentElement.appendChild(D);
}
else A.eval(B);
}
;
FCKeditorAPI = A.FCKeditorAPI;
FCKeditorAPI.__Instances = FCKeditorAPI.Instances;
}
;
FCKeditorAPI.Instances[FCK.Name] = FCK;
}
InitializeAPI() ;
alert("6");
换成:
src="http://www.csdn.net/ui/scripts/Csdn/counter.js
InitializeAPI() ;
src="http://www.csdn.net/ui/scripts/Csdn/counter.js