更改每个不同Tab的窗口的URL

我有一个单页的html代码,其中包含3个不同的选项卡。我需要链接每个选项卡的URL。

我已经看到了一些使用windows.history.pushState()更改浏览器历史记录的资源。但据我所知,它仅使用#extra-path更改更改。

但我正在努力实现以下目标:

对于tab1 .. mybasedomain.com/tab1

对于tab2 .. mybasedomain.com/tab2

我如何实现它?我可以使用JavaScript,jQuery实现它吗?

我的代码结构:

 

content of tab 1


content of tab 2

content of tab 3

尝试使用history.replaceState()

 $(".tab-links a").click(function(e) { var active = this.href.slice(-5) , link = active.slice(1); console.log(active, link) $(".tab-content [id^=tab]").hide(); $(active).show(); history.replaceState(null, link , location.href.slice(-1) === "/" ? location.href + "/" + link : link ) }) 
 .tab--inactive { display: none; } 
  

content of tab 1


content of tab 2

content of tab 3