html - 为带有哈希的 URL 设置不同的标题标签?

标签 html seo title

<分区>

我想知道是否可以为带有哈希的 URL 设置唯一的标题标签。

例如,我可以为这个页面取一个标题吗:

http://somesite.com

然后为这个 url 有一个单独的标题:

http://somesite.com#something

提前致谢!

最佳答案

这应该有帮助:

<html>
    <head>
        <title>Test Title</title>
        <script type="text/javascript">
            var url =document.URL; 
            if(url.indexOf('#')!=-1){
                document.title = "This is the new page title.";
            }
        </script>
    </head>
     <body>
         <a href="?#something">SomeLink</a>
    </body>    
</html>

关于html - 为带有哈希的 URL 设置不同的标题标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19914834/

相关文章:

swift - 如何在 MKAnnotationView 的标注中自定义标题/副标题字体或只是隐藏它们?

android - 如何更改微调器的标题

iphone - 使用字符串 "Settings"设置 Controller 标题不起作用

html - flex-container.min-width : flex-items. 最小宽度?

html - 如何为 tr 添加悬停到此 css 类?

.htaccess 301 http ://redirect to https://not being indexed by Google

seo - 将 h2 标签放在 span 标签中是否有效?

apache - 301 重定向到没有 .htaccess (myshopify.com) 和 SEO 排名问题的站点

jquery - 奇怪的悬停错误

php - 自动生成子页面