如何在JavaScript中调用函数,以便当我单击空白页然后调用函数?
function islToChr(arg) {
d=parseInt(arg.HDay.value)
m=parseInt(arg.HMonth.value)
y=parseInt(arg.HYear.value)
jd=intPart((11*y+3)/30)+354*y+30*m-intPart((m-1)/2)+d+1948440-385
arg.JD.value=jd
arg.wd.value=weekDay(jd%7)
}
答案 0 :(得分:0)
你可以把这个函数作为自调用函数表达式(自动执行函数)
(function islToChr(arg) {
d=parseInt(arg.HDay.value)
m=parseInt(arg.HMonth.value)
y=parseInt(arg.HYear.value)
jd=intPart((11*y+3)/30)+354*y+30*m-intPart((m-1)/2)+d+1948440-385
arg.JD.value=jd
arg.wd.value=weekDay(jd%7)
})(arg)
答案 1 :(得分:0)
如果要单击空白页面上的任意位置然后调用该函数,请尝试
function islToChr(arg) {
d=parseInt(arg.HDay.value)
m=parseInt(arg.HMonth.value)
y=parseInt(arg.HYear.value)
jd=intPart((11*y+3)/30)+354*y+30*m-intPart((m-1)/2)+d+1948440-385
arg.JD.value=jd
arg.wd.value=weekDay(jd%7)
}
document.onclick = function(){
islToChr();//you can pass the argument as you wish
};