有问题求教各位啊!
jslet.jsp文件主要代码:
<head>
<script language= "javascript ">
function test()
{
<% response.sendRedirect( "head.jsp ");%>
}
</script>
</head>
<body>
<input type= "button " name= "test " value= "test " onclick= "test() "/>
</body>
</html>
问题是:
怎么我打开jslet.jsp文件后就立即跳转到head.jsp里去了呢..
根本就没发生过onclick事件啊!
------解决方案-------------------- <% response.sendRedirect( "head.jsp ");%> 是在服务器端执行的代码,运行至此处即会跳转,与javascript无关.
------解决方案--------------------是的,服务端和客户端要区分清楚
------解决方案--------------------jslet.jsp页面从上向下执行到: <% response.sendRedirect( "head.jsp ");%> 时即重定向,不会再执行后面的代码:
}
</script>
</head>
<body>
<input type= "button " name= "test " value= "test " onclick= "test() "/>
</body>
</html>
------解决方案--------------------你希望实现的可以这样写:
<script language= "javascript ">
function test()
{
location.href = "head.jsp ";
}
</script>