document.write("<%SendTest st = new SendTest()%>");为什么出错??
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="com.test.SendTest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function send()
{
document.write("haha");
document.write("<%SendTest st = new SendTest()%>");
document.write("<st.str()>");
document.write("haha");
}
</script>
<body>
<input type="button" NAME="Button" VALUE="单击这里看看效果" onclick="send()">
</body>
</html>
问题点数:20、回复次数:3Top
1 楼wizardblue()回复于 2006-03-11 10:36:29 得分 5
("<%SendTest st = new SendTest()%>");
要加一个分号,表示语句结束
("<%SendTest st = new SendTest();%>");Top
2 楼sheep219(sheep219)回复于 2006-03-11 10:43:00 得分 5
同上Top
3 楼yingtju(蚂蚁)回复于 2006-03-11 11:14:43 得分 10
你的java代码实在服务器端执行的
而javascript是客户端执行的
这样改试试:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="com.test.SendTest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function send(haha)
{
document.write(haha);
}
</script>
<body>
<input type="button"
NAME="Button"
VALUE="单击这里看看效果"
onclick="send('<%=new SendTest().str()%>')">
</body>
</html>
Top




