[英]How to read client machine time in pageload event?
I am using javascript to get client date as below 我正在使用javascript获取客户日期,如下所示
function getDate() {
var dt = new Date();
return (dt);
}
I want this value in pageload ? 我要在页面加载中使用此值吗? How to assign javascript return value to a variable ? 如何将javascript返回值分配给变量? after page load javascript is calling , but I want the result to the variable in the pageload. 页面加载后javascript正在调用,但是我希望结果返回到页面加载中的变量。
尝试像这样在pageload事件的window对象中设置一个值;
window.loadDateTime = getDate();
There is window.onload
event which is called when the DOM
is loaded. 加载DOM
时会调用window.onload
事件。 You can attach this function as a handler to that event. 您可以将此函数作为该事件的处理程序附加。
window.onload=function()
{
var dateNow=getDate()
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.