请问高手:父窗口执行子frame的全局函数,与子frame自己执行该函数结果不一样。

eduyu 2008-02-28 10:12:11
不知道该怎么找原因,请高手透露些经验 :)

谢了
...全文
155 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
eduyu 2008-03-11
  • 打赏
  • 举报
回复
请问还需要哪个部分的代码?
这全是FCKeditor的代码,我的代码只有两行,就是我在一楼说的:

在FCKeditor的dialog窗口调用:
window.frames[0].document.getElementsByName('spphotoform')[0].submit();
在FCKeditor的dialog的子窗口(window.frames[0])调用:
document.getElementsByName('spphotoform')[0].submit();
两个调用结果竟然不一样。
[img=http://iamduyu.googlepages.com/fckeditor_bug.jpg]http://iamduyu.googlepages.com/fckeditor_bug.jpg[/img]

目的是让FCKeditor提交表单。图片上的代码全是FCKdialog上的代码。全文如下:

//#### The OK button was hit.
function Ok()
{


var bHasImage = ( oImage != null ) ;
if ( !bHasImage )
{
oImage = FCK.CreateElement( 'IMG' ) ;
}
//else
//oEditor.FCKUndo.SaveUndoStep() ;


UpdateImage( oImage ) ;

var imgalignlist= new Array("","left","center","right");
var imgalign;
for(i=0;i<4;i++)
{
if(linkForm.spImgAlign1[i].checked)
{
imgalign = imgalignlist[i];
}
}
if ( !bHasDiv ){
if ( !bHasImage )
oEditor.FCKSelection.SelectNode( oImage ) ;
//var inhtml = oImage.outerHTML;
oDiv = FCK.CreateElement( 'DIV' ) ;
//ioDiv.innerHTML = inhtml;
oDiv.appendChild(oImage);

}

/*
var tmpDiv = FCK.CreateElement( 'DIV' );
tmpDiv.innerHTML = ' ';
tmpDiv.className = 'tmpDiv';
oDiv.parentNode.appendChild(tmpDiv);
*/
SetAttribute(oDiv,'align',imgalign);
SetAttribute(oDiv,'forimg',1);

if ( linkForm.spImgThumb1[0].checked==true && !bHasImage ){
var sLnkUrl = GetE('url').value.Trim();
if( (/^http:\/\/hiphotos.baidu.com/gi).test(sLnkUrl) )
sLnkUrl=sLnkUrl.replace("/abpic/","/pic/");
oEditor.FCKSelection.SelectNode( oImage ) ;
// oLink = oEditor.FCK.CreateLink(sLnkUrl ) ;


var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sLnkUrl ) ;
var aHasSelection = ( aLinks.length > 0 ) ;
if ( !aHasSelection )
{
sInnerHtml = sLnkUrl;
var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ;
var asLinkPath = oLinkPathRegEx.exec( sLnkUrl ) ;
if (asLinkPath != null)
sInnerHtml = asLinkPath[1]; // use matched path
aLinks = [ oEditor.FCK.CreateElement( 'a' ) ] ;
}
for ( var i = 0 ; i < aLinks.length ; i++ )
{
oLink = aLinks[i] ;

if ( aHasSelection )
sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL).

oLink.href = sLnkUrl ;
SetAttribute( oLink, '_fcksavedurl', sLnkUrl ) ;
oLink.innerHTML = sInnerHtml ; // Set (or restore) the innerHTML

SetAttribute( oLink, 'target', "_blank" ) ;
}
  • 打赏
  • 举报
回复
不给代码,是怕别人知道你的错误??
zwd2005 2008-03-11
  • 打赏
  • 举报
回复
window.frames['frmMain'].contentWindow.Ok()
zwd2005 2008-03-11
  • 打赏
  • 举报
回复
window.frames['frmMain'].contentWindow.Ok()
eduyu 2008-03-11
  • 打赏
  • 举报
回复
up
eduyu 2008-03-01
  • 打赏
  • 举报
回复
让我郁闷的是明明是存在的方法,却不能调用,导致我程序出错。
这是Js Engine的bug?
[img=http://iamduyu.googlepages.com/fckeditor_bug.jpg]http://iamduyu.googlepages.com/fckeditor_bug.jpg[/img]
  • 打赏
  • 举报
回复
具体代码最好,懒得去猜啊!
eduyu 2008-03-01
  • 打赏
  • 举报
回复
代码在第一个回复,发布的之后忘记了 :(
No_Data_Found 2008-02-29
  • 打赏
  • 举报
回复
老规矩 放代码
myvicy 2008-02-29
  • 打赏
  • 举报
回复
怎么不一样了,你得描述清楚点。
  • 打赏
  • 举报
回复
不一样?
xiaojing7 2008-02-29
  • 打赏
  • 举报
回复
看见是100分的,进来留个名字,时间不早了,先睡觉了
eduyu 2008-02-28
  • 打赏
  • 举报
回复
类似于这样:
window.frames[0].document.getElementsByName('spphotoform')[0].submit();
与子frame:
document.getElementsByName('spphotoform')[0].submit();

竟然结果不一样。。。。。
晕了

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧