js文件是导入的
<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ page import="java.util.*"%>
<html>
<head >
<script src="/js/Calendar5.js" type="text/javascript"></script> <script type="text/javascript">
var c = new Calendar("c");
document.write(c);
</script></head>
<body>
<form id="form1">
<div>
普通调用:<input type="text" name="txt1" id="txt1" onfocus="c.showMoreDay = false;c.show(this);" /><br />
<div style="height: 262px">
</div>
按钮调用:<input type="text" name="btntxt" id="btntxt" /><input name="button" value="*"
id="button" type="button" onclick="c.showMoreDay = true;c.show(getObjById('btntxt'),'1982-1-1',this)" />
<br />
<input type="text" name="btntxt3" id="btntxt3" /><input name="button3" value="*"
id="button3" type="button" onclick="c.showMoreDay = true;c.show(this,getObjById('btntxt3'))" />
</div>
</form>
</body>var c = new Calendar("c");这句中的Calendar未定义?
<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ page import="java.util.*"%>
<html>
<head >
<script src="/js/Calendar5.js" type="text/javascript"></script> <script type="text/javascript">
var c = new Calendar("c");
document.write(c);
</script></head>
<body>
<form id="form1">
<div>
普通调用:<input type="text" name="txt1" id="txt1" onfocus="c.showMoreDay = false;c.show(this);" /><br />
<div style="height: 262px">
</div>
按钮调用:<input type="text" name="btntxt" id="btntxt" /><input name="button" value="*"
id="button" type="button" onclick="c.showMoreDay = true;c.show(getObjById('btntxt'),'1982-1-1',this)" />
<br />
<input type="text" name="btntxt3" id="btntxt3" /><input name="button3" value="*"
id="button3" type="button" onclick="c.showMoreDay = true;c.show(this,getObjById('btntxt3'))" />
</div>
</form>
</body>var c = new Calendar("c");这句中的Calendar未定义?
js的引用路径不对吧
<script src="${pageContext.request.contextPath}/js/Calendar5.js" type="text/javascript"></script>
function Calendar(objName)
{
this.style = {
borderColor : "#909eff", //边框颜色
headerBackColor : "#909EFF", //表头背景颜色
headerFontColor : "#ffffff", //表头字体颜色
bodyBarBackColor : "#f4f4f4", //日历标题背景色
bodyBarFontColor : "#000000", //日历标题字体色
bodyBackColor : "#ffffff", //日历背景色
bodyFontColor : "#000000", //日历字体色
bodyHolidayFontColor : "#ff0000", //假日字体色
waterColor : "#d4d4d4", //背景水印色
moreDayColor : "#cccccc"
};
this.showMoreDay = false; //是否显示上月和下月的日期
this.Obj = objName;
this.date = null;
this.mouseOffset = null;
this.dateInput = null;
this.timer = null;
};
应该是这个方法吧,js不太懂
<script src="/js/Calendar5.js" type="text/javascript"></script>
楼上的说的对
不管你的jsp发布到什么容器里
/js/Calendar5.js这样的写法会给你定义到web窗口的根目录里
比如 发布路径是 http://127.0.0.1:8080/testproject
按照你的写法会把js定位到http://127.0.0.1:8080/js/Calendar5.js
看错误 就是引用路径不对写成这样应该就可以了
<script src="<%=request.getContextPath() %>/js/Calendar5.js" type="text/javascript"></script>