How to dynamically change a web page's title?

前端 未结 19 1860
遇见更好的自我
遇见更好的自我 2020-11-22 08:05

I have a webpage that implements a set of tabs each showing different content. The tab clicks do not refresh the page but hide/unhide contents at the client side.

No

19条回答
  •  醉话见心
    2020-11-22 08:37

    One way that comes to mind that may help with SEO and still have your tab pages as they are would be to use named anchors that correspond to each tab, as in:

    http://www.example.com/mypage#tab1, http://www.example.com/mypage#tab2, etc.

    You would need to have server side processing to parse the url and set the initial page title when the browser renders the page. I would also go ahead and make that tab the "active" one. Once the page is loaded and an actual user is switching tabs you would use javascript to change document.title as other users have stated.

提交回复
热议问题