我知道document.write被认为是不好的做法; 我希望编制一份提交给第三方供应商的理由清单,说明为什么他们不应该document.write在分析代码的实现中使用它们.
请在下面提供您声称document.write为不良做法的理由.
function timeClock()
{
setTimeout("timeClock()", 1000);
now = new Date();
alert(now);
f_date = now.getDate()+" "+strMonth(now.getMonth())+" "+now.getFullYear()+" / "+timeFormat(now.getHours(), now.getMinutes());
return f_date;
}
<span class="foo"><script type="text/javascript">document.write(timeClock());</script></span>
Run Code Online (Sandbox Code Playgroud)
警报(现在的); 每秒给我一个值,但它没有在html中更新.如何在不刷新页面的情况下更新html的时间?