日期:2014-05-16  浏览次数:20388 次

JS 时间到后链接为空,我写了个但是只兼容IE,求兼容全部浏览器的代码
window.onload=function dare()
  {

  var futureday=new Date("March 29,00:00:00,2013");
  var nowday=new Date();
   
  var seconds=Math.floor((futureday.getTime() - nowday.getTime())/1000);
if(seconds>=0)
{
  var cseconds=seconds%60;
   
  var minutes=Math.floor(seconds/60);
  var cminutes=minutes%60;
   
  var hours=Math.floor(minutes/60);
  var chours=hours%24;
   
  var day=Math.floor(hours/24);
   
  var month=Math.floor(day/30);
  var year=Math.floor(month/12);
  var strer=day+"天"+chours+"小时"+cminutes+"分"+cseconds+"秒";
   
  document.getElementById("004").value = strer;
  setTimeout("dare()",1000);
}
if(seconds<0)
  {
var a101=document.getElementById("101");
a101.childNodes
var tim001=document.getElementById("004");
tim001.value="投票时间已过";
 
var ss=new Array();
var ss=document.getElementsByName("a002");
  var len=ss.length;

  for(var i=0;i<len;i++)
{
  var s=ss[i];
  s.href="";
  } 
}
else
{
 
 

   
  }
这个怎么改才兼容FF或者其他浏览器?或者有没有其他好的代码?

------解决方案--------------------
楼主 整理下你的demo,把能跑的贴出来
------解决方案--------------------
就目前来看。。并没有什么不兼容的地方