我需要创建一个在页面加载时打开并且仅在美国东部标准时间上午 11 点到晚上 7 点之间打开的弹出窗口。
我有自动弹出工作,但在添加时间差异时遇到了麻烦。
请指教。已编辑
<!--chat-->
<script type="text/javascript">
$(document).ready(function() {
var currentTime = new Date((new Date()).toUTCString());
var startTime = new Date((new Date()).toUTCString());
var endTime = new Date((new Date()).toUTCString());
startTime.setUTCHours(8);
endTime.setUTCHours(19);
//set times to EST. (UTC -5)
currentTime.setHours(currentTime.getHours() - 5);
startTime.setHours(startTime.getHours() - 5);
endTime.setHours(endTime.getHours() - 5);
//code to determine your variables goes here
var mylink = "https://mylink.com";
var windowname = "Chat Client";
if (currentTime < endTime && currentTime > startTime) {
popup(mylink, windowname);
}
});
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=470,height=700,scrollbars=yes');
return false;
}
</SCRIPT>