日期:2014-05-18  浏览次数:20923 次

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 ");

A