CNET中国旗舰网站

ZDNet China | CNET科技资讯网 | 政府采购 | 行业网站联盟





 
标题: [转贴] 父窗口对子窗口无法提交
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  楼主
发表于 2008-3-18 11:18  资料  个人空间  短消息  加为好友 
开发者在线

父窗口对子窗口无法提交

我在父窗口中的代码如下   
  <iframe   scrolling="no"   frameborder="0"   src="room.asp.php"   width="575"   height="600"   id="main"   name="subform"   align="right"   marginheight="0"   marginwidth="0"   >   
                                    </iframe>     
                                                <input        type="reset"   name="Submit1"   value="保存设置"   >   
   
  在父窗口中调用了子窗口中的一个JS函数SavePos()     
  函数代码如下   
    function   SavePos()     
    {     
  RoomForm.user_left.value=document.all.DIV_user.style.posLeft;   
  RoomForm.user_top.value=document.all.DIV_user.style.posTop;   
  RoomForm.friend_left.value=document.all.DIV_friend.style.posLeft;   
  RoomForm.friend_top.value=document.all.DIV_friend.style.posTop;   
    }     
   
  我现在想通过点击父窗口中的按钮实现对子窗口的FORM表单   RoomForm   的提交,请问该怎么实现   
   
  请知道的朋友帮忙一下!!!




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  沙发
发表于 2008-3-18 11:18  资料  个人空间  短消息  加为好友 
我自己尝试了在   SavePos()   中最后一行加上   RoomForm.submit()   而把那个按钮中的   window.subform.RoomForm.submit()   取消     
   
  调试结果都说网页有错误!!!




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  板凳
发表于 2008-3-18 11:18  资料  个人空间  短消息  加为好友 
try:   
  <input     onclick="window.frames['iframeId'].SavePos();"   type="reset"   name="Submit1"   value="保存设置"   >   
   
  同时   
  把RoomForm.submit()   写到iframe里的SavePos函数里




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  地毯
发表于 2008-3-18 11:18  资料  个人空间  短消息  加为好友 
修改后的代码   
  <iframe   scrolling="no"   frameborder="0"   src="room.asp.php"   width="575"   height="600"   id="subform"   name="subform"   align="right"   marginheight="0"   marginwidth="0"   >   
                                    </iframe>      
                                    <input   onclick="window.frames['subform'].SavePos();"   type="reset"   name="Submit1"   value="保存设置"   >   
   
  修改后的函数   
    function   SavePos()     
    {     
  RoomForm.user_left.value=document.all.DIV_user.style.posLeft;   
  RoomForm.user_top.value=document.all.DIV_user.style.posTop;   
  RoomForm.friend_left.value=document.all.DIV_friend.style.posLeft;   
  RoomForm.friend_top.value=document.all.DIV_friend.style.posTop;   
  RoomForm.submit();   
    }     
   
  还是有错误   不知道怎么回事了!!




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  第5楼
发表于 2008-3-18 11:18  资料  个人空间  短消息  加为好友 
请问能否用父页面按钮提交子页面   
  如果能的话,该怎么写这个!   
  可以   
   
  你的错误应该不在于父页面按钮的调用上,而是子页面的函数中。比如如下的语句是错误的:   
  RoomForm.user_left.value=document.all.DIV_user.style.posLeft;   
  正确应该是   
  document.RoomForm.user_left.value=document.all.DIV_user.style.posLeft(如果这后面没有错的话);   
   
   
  RoomForm.user_left.value=document.all.DIV_user.style.posLeft;等效于   
  window.RoomForm.user_left.value=document.all.DIV_user.style.posLeft;




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  第6楼
发表于 2008-3-18 11:18  资料  个人空间  短消息  加为好友 
父页面的全部代码如下:   
  <table   width="770"   border="0"   align="center"   cellpadding="0"   cellspacing="0"   bgcolor="#ecd4a2">   
          <tr>     
                      <td   height="30"   style="PADDING-left:   12px">   
      <?php   
      echo   $webname."   >>>   枫林小筑";   
      ?>   
      </td>   
                  </tr>   
   
      <tr>     
          <td>   
  <table   width="760"   height="374"   border="0"   align="center"   cellpadding="0"   cellspacing="0">   
                              <tr   valign="top">   
                                  <td   width="185"><table   width="98%"   height="62"   border="0"   cellpadding="0"   cellspacing="1"   bgcolor="#441308">   
                              <tr>     
                                  <td   height="25"> </td>   
                              </tr>   
                              <tr>     
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                              <tr>   
                                  <td   height="25"   bgcolor="#ecd4a2"> </td>   
                              </tr>   
                          </table></td>   
                                  <td>   
  <table   width="100%"   height="507"   border="0"   cellpadding="0"   cellspacing="1"   bgcolor="#441308">   
                              <tr>     
                                  <td   height="25"> </td>   
                              </tr>   
                              <tr>     
                                  <td   valign="top"   bgcolor="#ecd4a2">   
    <iframe   scrolling="no"   frameborder="0"   src="room.asp.php"   width="575"   height="600"   id="subform"   name="subform"   align="right"   marginheight="0"   marginwidth="0"   >   
                                    </iframe>     
    <br>   <br>   <br>   
                                    <input   onclick="window.subform['subform'].SavePos()"   type="reset"   name="Submit1"   value="保存设置"   >   
                                        </td>   
                              </tr>   
                          </table>   
   
  </td>   
                              </tr>   
                          </table>   
   
  </td>   
      </tr>   
      <tr>     
                      <td   height="5"></td>   
                  </tr>   
  </table>




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  第7楼
发表于 2008-3-18 11:19  资料  个人空间  短消息  加为好友 
子页面的全部代码   
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
  <link   rel="stylesheet"   href="../inc/default.css"   type="text/css">   
  <SCRIPT   LANGUAGE="JavaScript">   
  <!--   //   RightClickMenu   
   
  function   showmenu(){   
  var   rightedge=event.clientX   
  var   bottomedge=event.clientY   
  if   (rightedge>480)   
  ie5menu.style.left=480   
  else   
  ie5menu.style.left=rightedge+20   
  if   (bottomedge>480)   
  ie5menu.style.top=480   
  else   
  ie5menu.style.top=bottomedge   
  ie5menu.style.visibility="visible"   
  return   false   
  }   
   
  function   showmenu2(){   
  var   rightedge=event.clientX   
  var   bottomedge=event.clientY   
  if   (rightedge>480)   
  ie5menu2.style.left=480   
  else   
  ie5menu2.style.left=rightedge+20   
  if   (bottomedge>480)   
  ie5menu2.style.top=480   
  else   
  ie5menu2.style.top=bottomedge   
  ie5menu2.style.visibility="visible"   
  return   false   
  }   
   
  //   -->   
  var   cursorX,cursorY,obj=null;   
  var   moveAble=true;   
  function   enableMove(index){   
  cursorX=event.clientX;   
  cursorY=event.clientY;   
  obj=index;   
   
  }   
  function   img_border(obj){   
  obj.className="img_border"   
  }   
  function   no_img_border(obj){   
  obj.className=""   
  }   
   
  function   disableMove()   {obj=null;}   
  function   move_ie(){   
  if(obj   &&   moveAble){   
   
  DIV_name=obj.id;   
  moveX=event.clientX;   
  moveY=event.clientY;   
  if(moveX>550)   
  moveX=550;   
  if(moveX<10)   
  moveX=10;   
  if(moveY>480)   
  moveY=480;   
  if(moveY<10)   
  moveY=10;   
  document.all[DIV_name].style.posLeft+=moveX-cursorX;   
  document.all[DIV_name].style.posTop+=moveY-cursorY;   
  cursorX=moveX;     
  cursorY=moveY;   
  }   
   
  }   
   
    function   hidemenuie5()     
    {     
  ie5menu.style.visibility='hidden'   
  ie5menu2.style.visibility='hidden'   
    }     
  function   SavePos()     
  {     
  document.RoomForm.user_left.value=document.all.DIV_user.style.posLeft;   
  document.RoomForm.user_top.value=document.all.DIV_user.style.posTop;   
  document.RoomForm.friend_left.value=document.all.DIV_friend.style.posLeft;   
  document.RoomForm.friend_top.value=document.all.DIV_friend.style.posTop;   
  document.RoomForm.submit();   
  }     
  <!--   
  function   MM_reloadPage(init)   {     //reloads   the   window   if   Nav4   resized   
      if   (init==true)   with   (navigator)   {if   ((appName=="Netscape")&&(parseInt(appVersion)==4))   {   
          document.MM_pgW=innerWidth;   document.MM_pgH=innerHeight;   onresize=MM_reloadPage;   }}   
      else   if   (innerWidth!=document.MM_pgW   ||   innerHeight!=document.MM_pgH)   location.reload();   
  }   
  MM_reloadPage(true);   
  //-->   
  </script>   
  <SPAN   onmousemove=move_ie()     id=RoomSpan   style="Z-INDEX:   1;   WIDTH:   568px;   POSITION:   absolute;   TOP:   0px;   HEIGHT:   600px;   left:   1px;">   
  <form   action="?"   method="post"   name="RoomForm"   id="RoomForm">   
                          <table   width="568"   height="500"   border="0"   cellpadding="0"   cellspacing="0">   
                              <tr>   
                                  <td>   
  <IMG   src="../images/upload/2006/2006-12/2006-12-27/IMG_0151.gif"   width="600"   height="450"></td>   
                              </tr>   
                          </table>   
   
        <input   type="hidden"   name="user_left"   id="user_left">   
  <input   type="hidden"   name="user_top"   id="user_top">   
  <input   type="hidden"   name="user_z"   id="user_z">   
    <DIV   onmouseup=disableMove();   onmousedown=enableMove(this)   ;   oncontextmenu="return   showmenu()";   onMouseOver=img_border(this);   onMouseOut=no_img_border(this);   id=DIV_user   style="Z-INDEX:   2;   LEFT:   29px;   WIDTH:   80px;   POSITION:   absolute;   TOP:   208px;     ;     visibility:   visible   ;">   
    <IMG   src="../images/upload/2006/2006-12/2006-12-27/IMG_0153.gif">   </DIV>   
      <div   align="center">   
        
          <!--<input     onclick="SavePos()"   type="submit"   name="Submit1"   value="保存设置"   >-->   
          <input   type="button"   name="Submit"   value="刷新套房"   onClick="javascript:location.href='room_2.asp'">   
          </div>   
  </form>   
  </span>   
  <div   id="ie5menu"   style="position:absolute;   left:619px;   top:137px;   width:107px;   height:132px;   z-index:2;   visibility:   hidden;">   
      <div   align="center">   
          <table   width="100%"   height="100%"   border="0"   cellpadding="0"   cellspacing="0"   bgcolor="#F2CAB6">   
              <tr   >   
                  <td><div   align="center"   onMouseOut="this.style.backgroundColor='#F2CAB6'"   onMouseOver="this.style.backgroundColor='#EFF3FF'"     style="cursor:default   "><a   href="div_up.asp?type=1&username=xuenping&num=">上移一层</a></div></td>   
              </tr>   
              <tr>   
                  <td><div   align="center"   onMouseOut="this.style.backgroundColor='#F2CAB6'"   onMouseOver="this.style.backgroundColor='#EFF3FF'"   style="cursor:default   "><a   href="div_down.asp?type=1&username=xuenping">下移一层</a></div></td>   
              </tr>   
              <tr>   
                  <td><div   align="center"   onMouseOut="this.style.backgroundColor='#F2CAB6'"   onMouseOver="this.style.backgroundColor='#EFF3FF'"   style="cursor:default   "><a   href="div_top.asp?type=1&username=xuenping&num=">放到最前</a></div></td>   
              </tr>   
              <tr>   
                  <td><div   align="center"   onMouseOut="this.style.backgroundColor='#F2CAB6'"   onMouseOver="this.style.backgroundColor='#EFF3FF'"   style="cursor:default   "><a   href="div_bottom.asp?type=1&username=xuenping">放到最后</a></div></td>   
              </tr>   
              <tr>   
                  <td><div   align="center"   onMouseOut="this.style.backgroundColor='#F2CAB6'"   onMouseOver="this.style.backgroundColor='#EFF3FF'"     style="cursor:default   "><a   href="div_float.asp?type=1&username=xuenping">水平翻转</a></div></td>   
              </tr>   
   
          </table>   
      </div>   
  </div>   
   
   
  <script   language="JavaScript">   
  <!--   
  if   (document.all&&window.print){   
  ie5menu.className="cMenu"   
  //document.oncontextmenu=showmenuie5   
  document.body.onclick=hidemenuie5   
   
  }   
  //-->   
  </script>   
  <?php   
  echo   $_POST['user_left']."<br>";   
  echo   $_POST['user_top']."<br>";   
  ?>   
   
  麻烦知道的朋友帮忙看看   谢谢!!!




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  第8楼
发表于 2008-3-18 11:19  资料  个人空间  短消息  加为好友 
最方便最易用的整合搜索平台-同时搜   搜天下   搜遍天下   方便大家   
  同时搜网(www.tongshisou.com)   
  是一个集著名搜索引擎:百度,GOOGLE,YAHOO,中搜,爱问,搜狗,奇虎,腾讯搜搜,   
  OPENV,TVIX的整合搜索平台,目前包括网页,新闻,音乐,图片,视频,地图,电影,交友,论坛,博客,   
  工作   金融等资源搜索。http://www.tongshisou.com




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
  第9楼
发表于 2008-3-18 11:19  资料  个人空间  短消息  加为好友 
<input   onclick="window.subform['subform'].SavePos()"   type="reset"   name="Submit1"   value="保存设置"   >   
  改成:   
  <input   onclick="window.subform.SavePos()"   type="reset"   name="Submit1"   value="保存设置"   >   
  看看   window.subform就表示调用frame了。   
  另外在frame的SavePos函数中加一个alert().   
  如果点击按钮能够弹出这个alert,则说明调用没有问题。




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
mz89757053
版主
Rank: 7Rank: 7Rank: 7


UID 304999
精华 0
积分 6933
帖子 8295
威望 116
ZD币 1002 元
阅读权限 250
注册 2008-3-10
状态 离线
发表于 2008-3-18 11:19  资料  个人空间  短消息  加为好友 
document.RoomForm.friend_left.value=document.all.DIV_friend.style.posLeft;   
  document.RoomForm.friend_top.value=document.all.DIV_friend.style.posTop;   
   
  问题解决了!!!




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
 



当前时区 GMT+8, 现在时间是 2009-7-4 16:40

  Powered by Discuz! 5.5.0 © 2001-2007 Comsenz Inc.
Processed in 0.080748 second(s), 3/3 queries

清除 Cookies - 联系我们 - ZDNetChina中文社区 - 无图版