6

I created two frames which respectively contain two links.

When the first frame gets clicked, I would like to display a JSP page in the second frame.

But I can't get it to work. When the first frame gets clicked, it opens the JSP page in a new window.

I paste some of my code.

This is my main.jsp

<html>

  <frameset cols="50%,50%">
  <frame src="frame1.jsp">
  <frame src="frame2.jsp">
  </frameset>

</html>

frame1.jsp

<html>

  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Frame 1 with links</title>
  </head>

  <body>
    <body bgcolor="lightBlue">

      <h2>Java Tutorial</h2>
      <a href="subframe1.jsp" target="frame2.jsp"> tracking system</a>
      <a href="subframe2.jsp" target="frame2.jsp">data information</a>

  </body>

</html>

frame2.jsp

<html>

  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  </head>

  <body>
  </body>

</html>

subframe1.jsp

<html>

  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
  </head>

  <body>

    <form action="insertData.jsp" action="post" >

      DATA ID:<input type="text" name="data_id"><br>
      East:<input type="text" name="east"><br>
      North:<input type="text" name="north"><br>
      <input type="submit" value="Save">
    </form>

  </body>
</html>

How can I fix that?

4

1 回答 1

1

首先我必须说 -框架集很糟糕,如果你可以避免使用它们,那么就这样做。

也就是说,链接的目标值必须是框架名。

你还没有命名你的框架,你需要指定一个名称属性。

所以你需要改变你的框架集看起来更像:

<frameset cols="50%,50%">
<frame name="frame1" src="frame1.jsp">
<frame name="frame2" src="frame2.jsp">
</frameset>

然后相应地更改您的链接:

<a href="subframe1.jsp" target="frame2"> tracking system</a>
<a href="subframe2.jsp" target="frame2">data information</a>
于 2014-02-13T17:18:33.787 回答