竹笋

注册

 

发新话题 回复该主题

详解前端工程师常考面试题js中的刷新, [复制链接]

1#
北京哪里能治愈白癜风 http://pf.39.net/bdfyy/bjzkbdfyy/

刷新当前页面

replace方法,该方法通过指定URL来替换当前缓存在history(客户端)中的items,所以使用replace方法后,无法访问已经被“forward”和“backward”替换的URL。reload方法,强制浏览器刷新当前页面。返回并刷新页面:

location.replace(document.referrer);document.referrer//前一个页面的URL

不要用history.go(-1),或history.back();来返回并刷新页面,这两种方法不会刷新页面。附:

1,history.go(0)2,location.reload()3,location=location4,location.assign(location)5,document.execCommand(Refresh)6,window.navigate(location)7,location.replace(location)8,document.URL=location.href

打开新窗口

1.超链接ahref=

分享 转发
TOP
发新话题 回复该主题