Skip to content

Morepractice/js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

js学习

  • 刷新页面
  1. 使用reload(flag),flag默认为true,当为true时,以get方式从服务器获取页面并刷新,当为false时,则从浏览器获取页面刷新;

  2. 使用replace(url),将以新的url代替原来的页面,与*location = 'url'*的区别为此种方式不可回退到原来的页面;

  3. 其它页面刷新方式;

history.back(); //退回上一个页面
history.go(-1); //-1代表上一个页面,1代表下个页面,依此类推
  1. 自动刷新页面;
function refreshPage(){
    window.location.reload();
}

setTimeOut(refreshPage,1000);//也可使用setInterval方法,单位ms
  1. setInterval与setTimeout区别:

setInterval为每隔一段时间执行一次即执行无限次,setTimeout代表隔几秒执行一次;最小执行时间,setInterval为10ms,setTimeout为4ms

function fn(){
    console.log(111);
}

setInterval(fn,1000);

//相当于(区别:)

setTimeout(function fn(){
    console.log(111);
    setTimeOut(fn,1000);
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published