大家好,有个问题向大家请教!
在一个html窗体(main.htm)中,有三个frame
<frameset framespacing="0" border="0" frameborder="0" rows="116,*,2%">
<frame name="top" scrolling="no" noresize target="middle" src="../pub/top.aspx">
<frame name="middle" target="bottom"  src="../middle.htm"
scrolling="auto" noresize>
<frame name="bottom" scrolling="no" src="../pub/boot.htm" 
noresize>
<noframes>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"
onmouseover="parent.status='HQS';return true"  >
<p>此网页使用了框架,但您的浏览器不支持框架。</p>
</body>
</noframes>
</frameset>现在,我想通过接收接收传递过来的参数,根据不同的参数值,指定middle这个frame的不同的src值,
如:main.htm?Aim=aaaa  ,我想将middle的src设置为:aaaa.aspx
不知道如何写,请大家指教!
我的javascript是这样写的
<script language=javascript >
enterDiffAim();
function enterDiffAim()  //进入页面后,根据传递进来的参数,进入 相应子页面
{
var url=window.location .href;
var aa=url.indexOf('='); if (aa == -1)
return ""; url=url.substring(aa+1);
 

if (url == "aaaa")
{
                                //这里不知道如何写了,
                                parent.document.frames("middle").document.location.href="../pub/aaaa.aspx";  //这样写不行
         }

</script>

解决方案 »

  1.   

    //这里不知道如何写了,
                                    parent.document.frames("middle").document.location.href="../pub/aaaa.aspx";  //这样写不行改为
    document.all.middle.src=="../pub/aaaa.aspx";
      

  2.   

    同意
    sprc_lcl(cool一生) 因为你这个javascript并没有在某一个frame中执行,而是在FrameSet所在的页面执行的
      

  3.   

    //这里不知道如何写了,
                                    parent.document.frames("middle").document.location.href="../pub/aaaa.aspx";  //这样写不行改为
    document.all["middle"].src="../pub/aaaa.aspx";
    或者:
    middle.src ="../pub/aaaa.aspx";
    或:
    middle.location.href = "../pub/aaaa.aspx";
    或:
    middle.location ="../pub/aaaa.aspx";你多试试
      

  4.   

    将你的script代码放在页面代码的最下边试试
      

  5.   

    sprc_lcl(cool一生) :谢谢你
    你所说的话到叶面代码的最下面是指的放到叶面的哪一个部分?
    是不是考虑执行代码的时候,没有初始化相应frame?
      

  6.   

    嗯,我看你把enterDiffAim();这句话放在最初了,就应该把script放在</frameset>的下边了
      

  7.   

    把所有代码放到这里,大家看一下:
    <%@ Page language="c#" Codebehind="main.aspx.cs" AutoEventWireup="false" Inherits="OT.HQS.Web.main" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    <head >
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
    <title>********系统</title>
    <script language=javascript >
     self.resizeTo(screen.availWidth,screen.availHeight);
    enterDiffAim()  ;  
    function enterDiffAim()  //进入页面后,根据传递进来的参数,进入 相应子页面
    {
    var url=window.location .href;
    var aa=url.indexOf('='); if (aa == -1)
    return ""; url=url.substring(aa+1);
     

    if (url == "aaaa")
    {
    alert(url);
    //window.middle .src="../pub/boot.htm" ;
    //window.parent.frames['middle'].location.href =
     
    //parent.document.frames("main").document.all.txtclassid.value=tmp;
    //parent.document.frames("middle").document.location.href="../pub/boot.htm";
    //document.all.middle.location.herf  = "../pub/boot.htm";
    //window.frames(1).location.href = "../pub/boot.htm" ;
     
    //document.all["middle"].src="../pub/boot.htm" ;
     
    //middle.src ="../pub/boot.htm" ;
     
    middle.location.href = "../pub/boot.htm" ;
     
    //middle.location ="../pub/boot.htm" ;  }

    </script>
    </head>
    <frameset framespacing="0" border="0" frameborder="0" rows="116,*,2%">
    <frame name="top" scrolling="no" noresize target="middle" src="../pub/top.aspx">
    <frame name="middle" target="bottom"  src="../middle.htm"
    scrolling="auto" noresize>
    <frame name="bottom" scrolling="no" src="../pub/boot.htm" 
    noresize>
    <noframes>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"
    onmouseover="parent.status='HQS';return true"  >
    <p>此网页使用了框架,但您的浏览器不支持框架。</p>
    </body >
    </noframes>
    </frameset>
    </html>
      

  8.   

    sprc_lcl(cool一生) :把script放在</frameset>的下边,如果去执行这个enterDiffAim()方法呢?
      

  9.   

    对,我是以为你是这样放的,应该放下边的,最少第一句:enterDiffAim()  ;这个你得放在</frameset>的下边
      

  10.   

    <%@ Page language="c#" Codebehind="main.aspx.cs" AutoEventWireup="false" Inherits="OT.HQS.Web.main" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    <head >
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
    <title>********系统</title>

    </head>
    <frameset framespacing="0" border="0" frameborder="0" rows="116,*,2%">
    <frame name="top" scrolling="no" noresize target="middle" src="../pub/top.aspx">
    <frame name="middle" target="bottom"  src="../middle.htm"
    scrolling="auto" noresize>
    <frame name="bottom" scrolling="no" src="../pub/boot.htm" 
    noresize>
    <noframes>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"
    onmouseover="parent.status='HQS';return true"  >
    <p>此网页使用了框架,但您的浏览器不支持框架。</p>
    </body >
    </noframes>
    </frameset>
    </html>
    <script language=javascript >
     self.resizeTo(screen.availWidth,screen.availHeight);
    enterDiffAim()  ;  
    function enterDiffAim()  //进入页面后,根据传递进来的参数,进入 相应子页面
    {
    var url=window.location .href;
    var aa=url.indexOf('='); if (aa == -1)
    return ""; url=url.substring(aa+1);
     

    if (url == "aaaa")
    {
    alert(url);
    //window.middle .src="../pub/boot.htm" ;
    //window.parent.frames['middle'].location.href =
     
    //parent.document.frames("main").document.all.txtclassid.value=tmp;
    //parent.document.frames("middle").document.location.href="../pub/boot.htm";
    //document.all.middle.location.herf  = "../pub/boot.htm";
    //window.frames(1).location.href = "../pub/boot.htm" ;
     
    //document.all["middle"].src="../pub/boot.htm" ;
     
    //middle.src ="../pub/boot.htm" ;
     
    middle.location.href = "../pub/boot.htm" ;
     
    //middle.location ="../pub/boot.htm" ;  }

    </script>你就改成这样吧,应该可以的
      

  11.   

    middle.location.href = "../pub/boot.htm" ; 前一定要加document.all.的
      

  12.   

    sprc_lcl(cool一生):如果放到最后面,请问: self.resizeTo(screen.availWidth,screen.availHeight);
    enterDiffAim()  ;这两个方法怎么去调用执行呢?
      

  13.   

    ....改如下。。你抄下来就是了..........测不通就是代码有问题了。。<%@ Page language="c#" Codebehind="main.aspx.cs" AutoEventWireup="false" Inherits="OT.HQS.Web.main" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    <head >
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
    <title>********系统</title>
    </head><script language=javascript >
    self.resizeTo(screen.availWidth,screen.availHeight); function enterDiffAim()  //进入页面后,根据传递进来的参数,进入 相应子页面
    {
    var url=window.location .href;
    var aa=url.indexOf('='); if (aa == -1)
    return ""; url=url.substring(aa+1);
     

    if (url == "aaaa")
    {
    alert(url);
    //window.middle .src="../pub/boot.htm" ;
    //window.parent.frames['middle'].location.href =
     
    //parent.document.frames("main").document.all.txtclassid.value=tmp;
    //parent.document.frames("middle").document.location.href="../pub/boot.htm";
    //document.all.middle.location.herf  = "../pub/boot.htm";
    //window.frames(1).location.href = "../pub/boot.htm" ;
     
    //document.all["middle"].src="../pub/boot.htm" ;
     
    //middle.src ="../pub/boot.htm" ;
     
    middle.location.href = "../pub/boot.htm" ;
     
    //middle.location ="../pub/boot.htm" ;  }

    </script>
    <frameset framespacing="0" border="0" frameborder="0" rows="116,*,2%">
    <frame name="top" scrolling="no" noresize target="middle" src="../pub/top.aspx">
    <frame name="middle" target="bottom"  src="../middle.htm"
    scrolling="auto" noresize>
    <frame name="bottom" scrolling="no" src="../pub/boot.htm" 
    noresize>
    <noframes>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"
    onmouseover="parent.status='HQS';return true"  >
    <p>此网页使用了框架,但您的浏览器不支持框架。</p>
    </body >
    </noframes>
    </frameset>
    </html>
    <script language=javascript>
    enterDiffAim();
    </script>
      

  14.   

    ....改如下。。你抄下来就是了..........测不通就是代码有问题了。。<%@ Page language="c#" Codebehind="main.aspx.cs" AutoEventWireup="false" Inherits="OT.HQS.Web.main" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    <head >
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
    <title>********系统</title>
    </head><script language=javascript >
    self.resizeTo(screen.availWidth,screen.availHeight); function enterDiffAim()  //进入页面后,根据传递进来的参数,进入 相应子页面
    {
    var url=window.location .href;
    var aa=url.indexOf('='); if (aa == -1)
    return ""; url=url.substring(aa+1);
     

    if (url == "aaaa")
    {
    alert(url);
     
    document.all.middle.location.href = "../pub/boot.htm" ;
    }

    </script>
    <frameset framespacing="0" border="0" frameborder="0" rows="116,*,2%">
    <frame name="top" scrolling="no" noresize target="middle" src="../pub/top.aspx">
    <frame name="middle" target="bottom"  src="../middle.htm"
    scrolling="auto" noresize>
    <frame name="bottom" scrolling="no" src="../pub/boot.htm" 
    noresize>
    <noframes>
    <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"
    onmouseover="parent.status='HQS';return true"  >
    <p>此网页使用了框架,但您的浏览器不支持框架。</p>
    </body >
    </noframes>
    </frameset>
    </html>
    <script language=javascript>
    enterDiffAim();
    </script>
      

  15.   

    sprc_lcl(cool一生) :谢谢你,好像还是不行,我想在 <body>里加一个 onload事件,在onload事件里调 用enterDiffAim()方法,不过好像也不行!
    呵呵,谢谢你了,我再试一下,看一下有没有其它问题,谢谢你!!
      

  16.   

    我刚才测了一下,页面内用的JS在<frameset>后面完全不执行,在前面你又取不到frame...你再想其它途径吧,JS不行了
      

  17.   

    sprc_lcl(cool一生) :谢谢你,我也为这烦呢,呵呵,再试一下其它方法吧
    谢谢你了,