单击一个框架中的链接,然后在另一个框架中显示一个JSP [英] Click a link in one frame and display a JSP in the other frame
问题描述
我创建了两个分别包含两个链接的框架.
I created two frames which respectively contain two links.
单击第一帧时,我想在第二帧中显示一个JSP页面.
When the first frame gets clicked, I would like to display a JSP page in the second frame.
但是我无法使它正常工作.单击第一帧时,它将在新窗口中打开JSP页面.
But I can't get it to work. When the first frame gets clicked, it opens the JSP page in a new window.
我粘贴一些代码.
这是我的 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>
我该如何解决?
推荐答案
First I must say - Framesets are bad, if you can avoid using them then do so.
也就是说,链接的 target 值必须是框架名称.
That said, the target value of your links needs to be a framename.
您尚未命名框架,需要指定名称属性.
You have not named your frames, you need to specify a name attribute.
因此,您需要更改框架集,使其看起来更像:
So you need to change your frameset to look more like:
<frameset cols="50%,50%">
<frame name="frame1" src="frame1.jsp">
<frame name="frame2" src="frame2.jsp">
</frameset>
,然后相应地更改链接:
and then change your links accordingly:
<a href="subframe1.jsp" target="frame2"> tracking system</a>
<a href="subframe2.jsp" target="frame2">data information</a>
这篇关于单击一个框架中的链接,然后在另一个框架中显示一个JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!