<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!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=ISO-8859-1"><% String cp = request.getContextPath();%> <title>Insert title here</title><script>function fun(){ window.location.href="<%=cp %>/OnloadServlet";}function test(){ <%System.out.println("test");%>}function test1(){ <%System.out.println("test1");%>}</script></head><body onload="fun()"> </body></html> 異常:每次load頁面時 test(),test1()的方法就會執行,請問是為什么呢?
JSP里執行js的window.onload()方法異常
阿波羅的戰車
2018-09-21 10:10:09