Element.viewportOffset = function(forElement) {
var valueT = 0, valueL = 0;
var element = forElement;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
// Safari fix
if (element.offsetParent == document.body &&
element.style['position'] == 'absolute') break;
} while (element = element.offsetParent);
element = forElement;
do {
if (!BrowserType.Opera || element.tagName == 'BODY') {
valueT -= element.scrollTop || 0;
valueL -= element.scrollLeft || 0;
}
} while (element = element.parentNode);
return Element._returnOffset(valueL, valueT);
};
Element._returnOffset = function(l, t) {
var result = [l, t];
result.left = l;
result.top = t;
return result;
};
var Event;
if(!Event){
Event = {};
}
Event.stop = function(e){
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble = true;
}
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue = false;
}
}
Event.addListener = function(target, eventType, handler, flag){
if(document.attachEvent){
target.attachEvent("on"+eventType, handler);
}else if(document.addEventListener){
target.addEventListener(eventType, handler, flag);
}else{
target["on"+eventType] = handler;
}
}
Event.removeListener = function(target, eventType, handler, flag){
if(document.detachEvent){
target.detachEvent("on"+eventType, handler);
}else if(document.removeEventListener){
target.removeEventListener(eventType, handler, flag);
}else{
target["on"+eventType] = null;
}
}
Event.target = function(el){
if(el.srcElement){
return el.srcElement;
}else{
return el.target;
}
}
function initLocation(){
var p = Element.viewportOffset(_target);
var pp = document.viewport.getScrollOffsets();
calendar.style.left = p.left+pp.left+"px";
var height = _target.clientHeight;
calendar.style.top = p.top +pp.top+ height+5 +"px";
}
calendar.style.top = p.top +pp.top+ height+5 +"px";还显示参数无效
调用时显示'null' 为空或不是对象
<script type="text/javascript" language="javascript" src="../../Styles/calendar.js"></script>
<script>
window.onload = function () {
c1 = new JSCalendar(document.getElementById("transdate1"));
// c2 = new JSCalendar(document.getElementById("transdate2"));
function format(date) {
return date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate();
}
var dateEl = document.getElementById("transdate1")
dateEl.onDateChange = function (oldDate, newDate) {
}
// var dateEl1 = document.getElementById("transdate2")
// dateEl.onDateChange = function (oldDate, newDate) {
// }
}
<asp:TextBox ID="transdate1" runat="server"></asp:TextBox>
var dateEl = document.getElementById("transdate1")通过这个来获取的不对吗?
追答你不是想点击textbox显示出来日立控件吗?但是你textbox都没有调用js怎么能实现那?在textbox中添加点击事件,让他调用js,来实现显示日历,