当点击'试验记录信息'时,窗口便立即关闭,为什么呢??代码片段:<table width="100%" height="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr >
<td id="syjlxx" width="25%" align="center" height="20" background="../images/dcleft_bg.gif"><a href="javascript:tz('jl')">试验记录信息</a> </td>
<td id="sysbxx" width="25%" align="center" height="20" background="../images/dcleft_bg.gif"><a href="javascript:tz('sb')">申报信息</a></td>
<td id="sysbxx" align="center" height="20" background="../images/dcleft_bg.gif"></td>
</tr>
<tr>
<td height="70%" colspan="2">
<iframe name="frame" height="100%" width="100" src="blank.html"></iframe>
</td>
</tr>
</table>
<script>
function tz(lx){
if(lx=="jl"){
frame.location="sy_jl_mod.jsp";
}
else if(lx=="sb"){
frame.location="sy_gd_mod.jsp"; }
}
</script>
<tr >
<td id="syjlxx" width="25%" align="center" height="20" background="../images/dcleft_bg.gif"><a href="javascript:tz('jl')">试验记录信息</a> </td>
<td id="sysbxx" width="25%" align="center" height="20" background="../images/dcleft_bg.gif"><a href="javascript:tz('sb')">申报信息</a></td>
<td id="sysbxx" align="center" height="20" background="../images/dcleft_bg.gif"></td>
</tr>
<tr>
<td height="70%" colspan="2">
<iframe name="frame" height="100%" width="100" src="blank.html"></iframe>
</td>
</tr>
</table>
<script>
function tz(lx){
if(lx=="jl"){
frame.location="sy_jl_mod.jsp";
}
else if(lx=="sb"){
frame.location="sy_gd_mod.jsp"; }
}
</script>
可以为iframe制定一个id,如id是frame,然后可以这样写:
docuement.getElementById("frame").src='你要到达的文件'
这样的写法也支持firefox
试了frame.src='',没反应;
试了docuement.getElementById("frame").src='你要到达的文件' ,窗口还是会关闭!
非常郁闷啊,不知各位还有什么意见没?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<table width="100%" height="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr >
<td id="syjlxx" width="25%" align="center" height="20" background="../images/dcleft_bg.gif"> <a href="javascript:tz('jl')"> 试验记录信息 </a> </td>
<td id="sysbxx" width="25%" align="center" height="20" background="../images/dcleft_bg.gif"> <a href="javascript:tz('sb')"> 申报信息 </a> </td>
<td id="sysbxx" align="center" height="20" background="../images/dcleft_bg.gif"> </td>
</tr>
<tr>
<td height="70%" colspan="2">
<iframe id="frame" height="100%" width="100%" src="blank.html"> </iframe>
</td>
</tr>
</table>
<script>
function tz(lx)
{
if(lx=="jl")
{
document.getElementById("frame").src="http://www.google.com";
}
else if(lx=="sb")
{
document.getElementById("frame").src="http://www.baidu.com";
}
}
</script>
</body>
</html>
<iframe id="frame" width="100%" height="400" src="blank.html"></iframe>
这是sygl_list.jsp
var aa=window.showmodaldw(public_sygl.jsp?dqjd=<%=dqjd%>&bh_syjl='+document.all.bh_syjl.value,jl,'dialogWidth:700px;dialogHeight:350px;scroll:no;');public_sygl.jsp完整代码:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ include file="../base.jsp"%>
<%
String bh_syjl=com.Checknull(request.getParameter("bh_syjl"));
String dqjd=com.Checknull(request.getParameter("dqjd"));
String xs=com.Checknull(request.getParameter("xs"));
try{
String title="试验情况信息";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css/style.css" rel="stylesheet" type="text/css" ></link>
</head>
<script language="javascript" src="../script/datecontrol.js"></script>
<script src="../script/Common.js"></script>
<script>
var CalendarWebControl1 = new atCalendarControl();
function btqh(id){td_jlxx.background="../images/line.gif";
td_sbxx.background="../images/line.gif";
id.background="../images/dcleft_bg.gif";}</script>
<title><%=title%></title>
<base target="_self">
<style type="text/css">
<!--
.TIL { font-family: "宋体"; font-size: 10pt; font-weight: normal; color: #CC6600}
a:link {
text-decoration: none;
color: #0000CC;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
color: #00FF00;
}
a:active {
text-decoration: none;
color: #000000;
}body,td,th {
font-family: 宋体;
font-size: 9pt;
}
-->
</style>
<body topmargin=1 leftmargin=1 >
<table width="100%" height="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#8BDBFA" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td id="td_jlxx" height="25" width="25%" align="center" background="../images/dcleft_bg.gif" onClick="javascript:btqh(this);"><a href="javascript:tz('jl')">试验记录信息</a></td>
<td id="td_sbxx" height="25" width="25%" align="center" background="../images/line.gif" onClick="javascript:btqh(this);"><a href="javascript:tz('sb')" >申报信息</a></td>
<td id="td_dd" height="25" width="50%" align="center" background="../images/line.gif"> </td>
</tr>
<tr>
<td height="100%" colspan="6" >
<iframe name="Frame" id="Frame" marginwidth=0 marginheight=0 frameborder=0 width="100%" scrolling="auto" height="100%" src="sy_jl_mod.jsp?dqjd=<%=dqjd%>&bh_syjl=<%=bh_syjl%>&xs=<%=xs%>"></iframe></td>
</tr>
<input type="hidden" name="bh_syjl" id="bh_syjl" value="<%=bh_syjl%>">
</table>
<script>
function tz(lx){
//alert("222323");
if(lx=="jl"){
document.getElementById("Frame").src="sy_jl_mod.jsp?bh_syjl=<%=bh_syjl%>&xs=<%=xs%>";
//Frame.src="sy_jl_mod.jsp?bh_syjl=<%=bh_syjl%>&xs=<%=xs%>";
}else if(lx=="sb"){
Frame.src='sy_sb_mod.jsp?bh_syjl=<%=bh_syjl%>&xs=mx&dqjd=031';
}
} </script>
</body>
</html>
<%}catch(Exception e){out.print(e.toString());}%>
这样是取得当前标签.
而HaIframe.src是设置标签src属性,这样是可以取得效果的而
window.MyIframe.location.href = ""
是级别进入到MyIframe后设置窗体的地址。