Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document.(我在Ruby on Rails中使用了一些嵌套布局,在其中一个布局中,我需要读取div中的字符串并将其设置为文档的标题。)

What is correct way (if any) to set the title of the document?(设置文档标题的正确方法是什么(如果有的话)?) <script type="text/javascript"> $(document).ready(function() { // ??? }); </script>   ask by Jason Miesionczek translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
233 views
Welcome To Ask or Share your Answers For Others

1 Answer

The following should work but it wouldn't be SEO compatible.(以下应该可以工作,但它不会与SEO兼容。)

It's best to put the title in the title tag.(最好将标题放在标题标签中。) <script type="text/javascript"> $(document).ready(function() { document.title = 'blah'; }); </script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...