首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

IFRAME如何使用

2012-01-22 
IFRAME怎么使用INDEX.HTML里有A,B二个按钮,我想点A按钮的时候在INDEX.HTML显示一组数据,点B按钮的时候还是

IFRAME怎么使用
INDEX.HTML里有A,B二个按钮,我想点A按钮的时候在INDEX.HTML显示一组数据,点B按钮的时候还是在INDEX.HTML里显示另一组数据

希望朋友们可以提供一下完全的源码,不要留下片段代码
兄弟先谢过了

[解决办法]
点击按钮时改变iframe对应的window的lication就可以了
[解决办法]
JS
onclick= "return check( 'url '); "
function check(url)
{
document.iframe1.src=url;
return true;
}


[解决办法]
使用 <iframe> ,通过测试。。。

******************index.html***********************
<%@ page language= "java " import= "java.util.* " pageEncoding= "GBK "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'test.jsp ' starting page </title>
<script type= "text/javascript ">
function changeUrl()
{
document.getElementById( "myframe ").src= "servlet1 ";
}
</script>
</head>
<body>
<input type= "submit " onclick= "changeUrl(); " value= "请点这里 ">
<iframe id= "myframe " width= "400 " height= "400 " src= "aaa.html "> </iframe>
</body>
</html>

*****************show.jsp********************
<%@ page language= "java " import= "java.util.* " pageEncoding= "UTF-8 "%>
<%@taglib uri= "http://java.sun.com/jsp/jstl/core " prefix= "c "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'show.jsp ' starting page </title>
</head>
<body>
<c:forEach items= "${array} " var= "temp ">
${temp.uname} <hr>
${temp.uaddress}
</c:forEach>
</body>
</html>

*****************Userinfo.java**********************
public class Userinfo {

private String uname;
private String uaddress;

public String getUaddress() {
return uaddress;
}
public void setUaddress(String uaddress) {
this.uaddress = uaddress;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
}

*****************Servlet1.java*********************
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Servlet1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType( "text/html ");

Userinfo u = new Userinfo();
u.setUname( "javaboy ");
u.setUaddress( "china ");

ArrayList a = new ArrayList();
a.add(u);
request.setAttribute( "array ", a);
request.getRequestDispatcher( "show.jsp ").forward(request, response);
}
}

热点排行