假设有A.htm、B.htm两页,A.htm:
<div id=aaa></div><iframe width=0 height=0src=b.htm></iframe>
B.htm:
<script>parent.aaa.innerHTML='test!'</script>那我如何在A页面刷新B页面呢?

解决方案 »

  1.   

    给你的iframe定义一个namedocument.frames('ifrmname').location.reload()
    document.all.ifrmname.document.location.reload()定义一个ID
    ifrmid.window.location.reload()
      

  2.   

    谢谢这个方法不错~~但是还有个问题~~我发现这样点击刷新还是全页面刷新额~~为什么不是局部刷新的?<tr>
                            <td width="100">用户名</td>
                            <td width="150"><input type="text" name="username" id="username" size="20"></td>
                        </tr>
                        <tr>
                            <td>密码</td>
                            <td><input type="password" name="password" id="password" size="21"></td>
                        </tr>
                        <tr>
                            <td>验证码</td>
                            <td><input type="text" id="Verification" name="Verification" value="" size="2">&nbsp<span id="VerCode"></span><iframe width=0 height=0 id="vc" name="vc" src=image.jsp></iframe></br><a href=""  onclick="reload()">换一张</a></td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center"><input type="submit" value="登陆"><input type="reset" value="重置"></td>
                        </tr>image页面:
    <script language="JavaScript">
    function reloadcode(){
    parent.VerCode.innerHTML = "<input type=\"image\" src=\"VerficationServlet\" disabled>";
    }
    </script>
      </head>
      
      <body onload="reloadcode()">
        
      </body>
      

  3.   

    ajax,或者jquery解决吧,很简单的。
      

  4.   

    ajax不太清楚如何传图片出来~~~
      

  5.   


    在子页面里通过js往父页面传递图片的path,在父页面里顶一个隐藏域来接收这个对应的路径,这样就能是实现图片浏览了  <c:if test="${!empty(requestScope.path)}">
      <script>
      parent.document.getElementById("path").value="${requestScope.path}";
      parent.document.getElementById("view").innerHTML="<img src=\"${pageContext.request.contextPath}/${requestScope.path}\" height='200 width='200'/> "
      </script>
      </c:if>[code=text]
    <tr>
    <td>
    图片
    </td>
    <td>
    <iframe
    src="${pageContext.request.contextPath }/upload.jsp?path=${requestScope.product.path}"
    width="100%" height="25" marginheight="0" marginwidth="0"
    scrolling="no" frameborder="0"></iframe>
    </td>
    </tr>
    <tr>
    <td>
    浏览
    </td>
    <td id="view">
    <c:if test="${empty(requestScope.product.path )}">
    &nbsp;
    </c:if> <c:if test="${!empty(requestScope.product.path)}">
    <img
    src="${pageContext.request.contextPath }/${requestScope.product.path}"
    width="200" height="200" />
    </c:if> </td>
    </tr>[/code]
      

  6.   

    嗯 想要用ajax来实现这些,可以在js里用ajax控制啊,包括图片浏览也可以在ajax返回的data路径结果在js里直接去处理
      

  7.   

    我有点不太理解~~~~~能这样嘛~我写个简单的你看看哪里不对?有一个登陆JSP就叫A.jsp还有个图片的jsp就叫B.jsp好了
    然后A页面代码:<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'MyJsp.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <script language="JavaScript">
    function reload(){
    vc.window.location.reload();
    }
    </script>
      </head>
      
      <body>
        <table>
         <tr>
    <td>验证码</td>
       <td><input type="text" id="Verification" name="Verification" value="" size="2">&nbsp<span id="VerCode"></span><iframe width=0 height=0 id="vc" name="vc" src=b.jsp></iframe></br><a href=""  onclick="reload()">换一张</a></td>
            </tr>
        </table>
      </body>
    </html>然后B.jsp:<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'image.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <script language="JavaScript">
    function reloadcode(){
    parent.VerCode.innerHTML = "<input type=\"image\" src=\"VerficationServlet\" disabled>";
    }
    </script>
      </head>
      
      <body onload="reloadcode()">
        
      </body>
    </html>你看下有什么问题吗? 
      

  8.   

    http://bbs.csdn.net/topics/390359666
    我之前也碰到类似的问题,可以看看我这个帖子,希望对你有帮助!