做网站注意事项,电商网站功能,四川省和城乡建设厅网站首页,如何建立自己的公司网站用法跟 location.href 一樣#xff0c;但用 replace 導到下頁後#xff0c;就不能再回到上一頁
Document.location.href和.replace的区别
document.location.href和document.location.replace都可以实现从A页面切换到B页面#xff0c;但他们的区别是#xff1a;用documen…用法跟 location.href 一樣但用 replace 導到下頁後就不能再回到上一頁
Document.location.href和.replace的区别
document.location.href和document.location.replace都可以实现从A页面切换到B页面但他们的区别是用document.location.href切换后可以退回到原页面。而用document.location.replace切换后不可以通过“后退”退回到原页面。
关于document.location.href或其他可回退的切换方式我还发现一个细节用个例子来说明假设有A.htm B.htm C.htm三个页面A.htm里有这样一句document.location.href/b.htm;b.htm里有这样一句document.location.href/c.htm;注意两个都是可回退的切换。1:当从A切换到B再切换到C时实际内存中保留了三个页面A、B、C2:回退到B时C页面被清出内存3:再次回退到A页面时B页面也被清出内存4:再次向前(不是用切换而是用向前)转到B页面时内存中保留的是A和B当一个文档被location.replace替换后它就会从当前的历史对象中移除了