首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

jsp调用年历控件IE提示未定义,求解

2012-12-14 
jsp调用日历控件IE提示未定义,急求解js文件是导入的%@ page pageEncodingutf-8 contentTypetext/htm

jsp调用日历控件IE提示未定义,急求解
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 />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
            <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未定义?

[最优解释]
你试试这个
<script src="${pageContext.request.contextPath}/js/Calendar5.js" type="text/javascript"></script>
[其他解释]
不是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>
[其他解释]
 <script src="/js/Calendar5.js" type="text/javascript"></script>
js的引用路径不对吧
[其他解释]

引用:
<script src="/js/Calendar5.js" type="text/javascript"></script>
js的引用路径不对吧


我根目录下有个js文件夹啊
[其他解释]


你调用java的Calendar?
[其他解释]

引用:
你调用java的Calendar?

应该不是吧,js里有个Calendar方法
function Calendar(objName)  
{
this.style = {
borderColor       : "#909eff", //边框颜色
headerBackColor    : "#909EFF", //表头背景颜色
headerFontColor    : "#ffffff", //表头字体颜色
bodyBarBackColor  : "#f4f4f4", //日历标题背景色
bodyBarFontColor  : "#000000", //日历标题字体色
bodyBackColor     : "#ffffff", //日历背景色
bodyFontColor            : "#000000", //日历字体色 
bodyHolidayFontColor     : "#ff0000", //假日字体色
watermarkColor     : "#d4d4d4",  //背景水印色
moreDayColor             : "#cccccc" 
};
this.showMoreDay = false; //是否显示上月和下月的日期
this.Obj = objName;
this.date = null;
this.mouseOffset = null;
this.dateInput = null;
this.timer = null;
};
。。。。。。
应该是这个方法吧,js不太懂

[其他解释]
引用:
你试试这个
<script src="${pageContext.request.contextPath}/js/Calendar5.js" type="text/javascript"></script>

咦,这个可行,这两路径有什么不同
[其他解释]
懂了,thanks

热点排行