js判断浏览器类型
function getOS(){
var OsObject = "";
if(navigator.userAgent.indexOf("MSIE")>0){
return "MSIE";
}
if(isFirefox = navigator.userAgent.indexOf("Firefox")>0){
return "Firefox";
}
if(isSafari = navigator.userAgent.indexOf("Safari")>0){
return "Safari";
}
if(isCamino = navigator.userAgent.indexOf("Camino")>0){
return "Camino";
}
if(isMozilla = navigator.userAgent.indexOf("Gecko/")>0){
return "Gecko";
}
}
alert("浏览器类型为:"+getOS());
js写一个当年还剩多少时间的倒计时
function counter(){
var date = new Date();
var year = date.getFullYear();
var date2 = new Date(year,12,31,23,59,59);
var time = (date2-date)/1000;
var day = Math.floor(time/(24*60*60))
var hour = Math.floor(time%(24*60*60)/(60*60))
var minute = Math.floor(time%(24*60*60)%(60*60)/60)
var second = Math.floor(time%(24*60*60)%(60*60)%60)
var str = year + "年还剩 "+day+"天"+hour+"时"+minute+"分"+second+"秒"
document.getElementById("id").value = str;
}
禁用浏览器前进后退
$(document).ready( function() {
window.history.forward( 1 );
window.history.forward( -1 );
})