function refresh(url, key){
var key= (key || 't') +'='; //默认是"t"
var reg=new RegExp(key+'\\d+'); //正则:t=1472286066028
var timestamp=+new Date();
if(url.indexOf(key)>-1){ //有时间戳,直接更新
return url.replace(reg,key+timestamp);
}else{ //没有时间戳,加上时间戳
if(url.indexOf('\?')>-1){
var urlArr=url.split('\?');
if(urlArr[1]){
return urlArr[0]+'?'+key+timestamp+'&'+urlArr[1];
}else{
return urlArr[0]+'?'+key+timestamp;
}
}else{
if(url.indexOf('#')>-1){
return url.split('#')[0]+'?'+key+timestamp+location.hash;
}else{
return url+'?'+key+timestamp;
}
}
}
}
在写实际代码之前做好CSS样式重置可避免一系列稀奇古怪的问题
body,ol,ul,h1,h2,h3,h4,h5,h6,p,th,td,dl,
dd,form,fieldset,legend,input,textarea,select{margin:0;padding:0}
body{font:12px "宋体","Arial Narrow",
HELVETICA;background:#fff;-webkit-text-size-adjust:100%}
a{text-decoration:none}
em{font-style:normal}
li{list-style:none}
img{border:0;vertical-align:middle}
table{border-collapse:collapse;border-spacing:0}
p{word-wrap:break-word}
网友评论