一直以来都是这么干的:
if( self != top ) { top.location.href = self.location.href; }
原来还可以这么搞:
if( self != top ) { top.location.replace(self.location.href); }
两者的区别就是,前者会被浏览器的返回按钮按钮记录下来,后者不会留下返回的痕迹。
本文探讨了使用JavaScript实现页面重定向的两种不同方法:一种是通过`top.location.href`,这种方法会被浏览器的历史记录所记录;另一种是使用`top.location.replace`,这种方式则不会留下返回的痕迹。文章通过具体的代码示例解释了这两种方法的区别。
if( self != top ) { top.location.href = self.location.href; }
原来还可以这么搞:
if( self != top ) { top.location.replace(self.location.href); }
两者的区别就是,前者会被浏览器的返回按钮按钮记录下来,后者不会留下返回的痕迹。

被折叠的 条评论
为什么被折叠?