当前位置:萝卜系统下载站 > 技术开发教程 > 详细页面

Iframe的妙用!

Iframe的妙用!

更新时间:2021-01-16 文章作者:未知 信息来源:网络 阅读次数:

近日写一段程序,要求从数据库表中读出纪录,每个纪录对应硬盘上的文件,这些文件全部是gif和swf文件,要求将这些gif和swf文件已4*4没页16个的形式显示在浏览器上,就像ACDSee那样。
由于数据库中的纪录是混乱的,gif和swf的排列顺序没有规则。对于gif文件,很好说,直接用<img src=<%=path%>>就可以显示出来,可是对于swf文件,就很麻烦,因为swf文件要在页面上显示的话,就要用到<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/download/swflash.cab#version=5,0,0,0" width="480" height="400">
<param name=movie value=http://cfan.net.cn/info/"images/man.swf">
<param name=quality value=high>
<embed src=http://cfan.net.cn/info/"images/man.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="480" height="400">
</embed>

这么长的代码非常讨厌,因此,我想到了一个很方便的方法:就是用iframe:
<iframe src=<%=Url%> scroll=auto marginwidth=0 marginheight=0 height=80% width=80% frameborder=0></iframe>

程序代码如下:

<%
String sqlStr;
String imgUrl;
String extendName;
ResultSet rs=null;
pageBean.setPageSize(PAGESIZE);
pageBean.setCurrentPage(request);

dbBean.connectIntranetDatabase();
pageBean.setDB(dbBean);
sqlStr="select * from datamanager.res_animation_a where publish=1 order by id desc";
rs=pageBean.page(sqlStr);

int count=0;
%>

<table border=1 cellpadding=0cellspacing=0 bordercolorlight='#666666' width=95% align=center class='font-default' bordercolordark='#FFFFFF' >

<%
if(rs!=null){
do
{
//显示字段内容
out.println("<tr>");
imgUrl=rs.getString("path");
extendName=rs.getString("filetype");
out.print("<td width=25% align=center valign=middle >");
if (extendName.trim().equals("gif")){
out.print("<a href=");
out.print(imgUrl);
out.print(">");
out.print("<img width='100' border=0 src=" + imgUrl + ">");
out.print("</a>");
}else{
out.print("<iframe src=");
out.print(imgUrl);
out.print(" scroll=auto marginwidth=0 marginheight=0 height=80% width=80% frameborder=0>");
out.print("</iframe>");
}
out.print("<br>");
out.print("<input type='checkbox' value='-1' name='");
out.print(rs.getString("id"));
out.print("'>");
out.print(rs.getString("name"));
out.print(".");
out.print(rs.getString("filetype"));
out.println("</td>");
count++;

out.print("<td width=25% align=center valign=middle >");
if (rs.next()){
imgUrl=rs.getString("path");
extendName=rs.getString("filetype");
if (extendName.trim().equals("gif")){
out.print("<a href=");
out.print(imgUrl);
out.print(">");
out.print("<img width='100' border=0 src=" + imgUrl + ">");
out.print("</a>");
}else{
out.print("<iframe src=");
out.print(imgUrl);
out.print(" scroll=auto marginwidth=0 marginheight=0 height=80% width=80% frameborder=0>");
out.print("</iframe>");
}
out.print("<br>");
out.print("<input type='checkbox' value='-1' name='");
out.print(rs.getString("id"));
out.print("'>");
out.print(rs.getString("name"));
out.print(".");
out.print(rs.getString("filetype"));
count++;
}
else{
out.print(" ");
}
out.println("</td>");

out.print("<td width=25% align=center valign=middle >");
if (rs.next()){
imgUrl=rs.getString("path");
extendName=rs.getString("filetype");
if (extendName.trim().equals("gif")){
out.print("<a href=");
out.print(imgUrl);
out.print(">");
out.print("<img width='100' border=0 src=" + imgUrl + ">");
out.print("</a>");
}else{
out.print("<iframe src=");
out.print(imgUrl);
out.print(" scroll=auto marginwidth=0 marginheight=0 height=80% width=80% frameborder=0>");
out.print("</iframe>");
}
out.print("<br>");
out.print("<input type='checkbox' value='-1' name='");
out.print(rs.getString("id"));
out.print("'>");
out.print(rs.getString("name"));
out.print(".");
out.print(rs.getString("filetype"));
count++;
}
else{
out.print(" ");
}
out.println("</td>");

out.print("<td width=25% align=center valign=middle >");
if (rs.next()){
imgUrl=rs.getString("path");
extendName=rs.getString("filetype");
out.print("<a href=");
out.print(imgUrl);
out.print(">");
out.print("<img width='100' border=0 src=" + imgUrl + ">");
out.print("</a>");

out.print("<br>");
out.print("<input type='checkbox' value='-1' name='");
out.print(rs.getString("id"));
out.print("'>");
out.print(rs.getString("name"));
out.print(".");
out.print(rs.getString("filetype"));
count++;
}
else{
out.print(" ");
}
out.println("</td>");


out.println("</tr>");

}while(rs.next() && count<PAGESIZE);
}
%>

温馨提示:喜欢本站的话,请收藏一下本站!

本类教程下载

系统下载排行

网站地图xml | 网站地图html