高分求助,解决问题马上结贴,,Iframe 嵌入jsp页面,并且从iframe传高和宽参数,要此jsp页面不能有滚动条,但要显示最多条数,不管多长标题,换行数不能超过2行,请高人帮忙 iframe.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0011)about:blank -->
<HTML> <HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3354" name=GENERATOR> </HEAD>
<BODY>
<table>
<tr>
<td>
<iframe name="main" width="50" height="150" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" noresize src="myJsp.jsp?width=50&height=150"> </iframe>
<!--这里的width 和height 都是作为参数传入到myjsp.jsp页面 -->
</td> </tr>
</table>
</BODY> </HTML>
myjsp.jsp <%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.fabu.InformUtil"%>
<%@ page import="com.fabu.ParamUtils"%>
<%@ page import="com.fabu.Inform"%>
<%
InformUtil util = new InformUtil();
util.setPageSize(100); //最大滚动条目假设不超过100
util.setCurrentPage(1);
//设定返回页面的信息
ArrayList list = util.getAllInfoListByPage();
//移动区域高度
int intHeight = ParamUtils.getIntParameter(request,"height",130);
//移动区域宽度
int intWidth = ParamUtils.getIntParameter(request,"width",200);
//显示颜色
String color = ParamUtils.getParameter(request, "color", "696969");
%> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> </title>
<style>a{TEXT-DECORATION:none} </style>
<style>
#asd td { border-bottom: 0px dotted #cecece;line-height:25px;}
</style>
</head>
<table cellpadding="0" csllspacing="0" align="left" width=" <%=intWidth%>" border="0" id="asd">
<tr>
<td valign="left">
<%
Inform info = null;
int count =0;
for(int i=0; i <list.size(); i++){
info = (Inform)list.get(i);%>
<a href=' <%=info.getUrl()%>' target=_blank>
<font color='blue' size=2> <%=title1%> </font>
</a> <br>
<%}%>
</td>
</tr>
</table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0011)about:blank -->
<HTML> <HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3354" name=GENERATOR> </HEAD>
<BODY>
<table>
<tr>
<td>
<iframe name="main" width="50" height="150" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" noresize src="myJsp.jsp?width=50&height=150"> </iframe>
<!--这里的width 和height 都是作为参数传入到myjsp.jsp页面 -->
</td> </tr>
</table>
</BODY> </HTML>
myjsp.jsp <%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.fabu.InformUtil"%>
<%@ page import="com.fabu.ParamUtils"%>
<%@ page import="com.fabu.Inform"%>
<%
InformUtil util = new InformUtil();
util.setPageSize(100); //最大滚动条目假设不超过100
util.setCurrentPage(1);
//设定返回页面的信息
ArrayList list = util.getAllInfoListByPage();
//移动区域高度
int intHeight = ParamUtils.getIntParameter(request,"height",130);
//移动区域宽度
int intWidth = ParamUtils.getIntParameter(request,"width",200);
//显示颜色
String color = ParamUtils.getParameter(request, "color", "696969");
%> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> </title>
<style>a{TEXT-DECORATION:none} </style>
<style>
#asd td { border-bottom: 0px dotted #cecece;line-height:25px;}
</style>
</head>
<table cellpadding="0" csllspacing="0" align="left" width=" <%=intWidth%>" border="0" id="asd">
<tr>
<td valign="left">
<%
Inform info = null;
int count =0;
for(int i=0; i <list.size(); i++){
info = (Inform)list.get(i);%>
<a href=' <%=info.getUrl()%>' target=_blank>
<font color='blue' size=2> <%=title1%> </font>
</a> <br>
<%}%>
</td>
</tr>
</table>
<tr>
<td valign="left" id="id1" width="<%=intWidth%>" height='<%=intHeght%>'>
<%
Inform info = null;
int count=0;
for(int i=0; i<list.size(); i++){
info = (Inform)list.get(i);%>
<a href='<%=info.getUrl()%>' target=_blank>
<% String title1 = info.getTitle();
int width=intWidth/25;
if(info.getTitle().length()>intWidth){title1=info.getTitle().substring(0,intWidth)+"...";}else
title1= info.getTitle();
%>
<font color='blue' size=2><%=title1%></font>
</a><br>
<%
count += allTitle.length();
int size = intHeight/(45);
if(i>size-2){
break ;
}%>
<%}
%>
</td>
</tr>
</table>
一个list记录,上下左右都不能出现滚动条,一条记录最多显示两行,记录条数以不出现滚动条为准。。
<table cellpadding="0" csllspacing="0" id="id2" align="left" width="100%" height="100%" border="1" id="asd"> <%
Inform info = null;
int count=0;
for(int i=0; i <list.size(); i++){
info = (Inform)list.get(i);%>
<tr> <td valign="left" id="id1"
<a href=' <%=info.getUrl()%>' target=_blank>
<%if(title.length > 两行字数)
%><%=title.substring()+"..."%>
<%else%><%=title%>
</td>
</tr> <%}
%>
</table>
这个帖子200分,都不能发言了,不知道怎么回事,CSDN也太烂了吧
比如这里你应该设置的就是iframe或者td的样式!
CSDN也太烂了吧,这句话有点伤人啊
这是我做系统得时候处理的办法不知道能不能有帮助
程序里面最关键得问题是你title1显式得内容不能够很好的控制。你可以取一下固定title1的字符。用substring函数,最多取5个汉字,其他的用省略号代替,反正你得程序还有超链接显示详细内容。我一般做系统的时候就是这样处理得。
String allTitle=title1;
int allTitleLength=allTitle.length()*13;
int sigleHang =0;
if(allTitleLength>intWidth){
sigleHang =2;
}else{ sigleHang =1;}
hangshu+=sigleHang ;
int width=intWidth/20;
if(info.getTitle().length()>width){title1=info.getTitle().substring(0,width)+"...";}else
title1= info.getTitle(); 楼主你看看。