日期:2014-05-19  浏览次数:20676 次

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文件夹啊
------其他解决方案--------------------