For those who are looking for a slightly more dynamic method that does a meta and a title at the same time and uses some casts:
<script type="text/javascript"> $(document).ready(function() { $title = ''; if($('h1:first').text() != '') { $title = $('h1:first').text(); document.title = document.title + " | " + $title; $('meta:first').attr('content', $title); } else if($('h2:first').text() != ''){ $title = $('h2:first').text(); document.title = document.title + " | " + $title; $('meta:first').attr('content', $title); } else if($('h3:first').text() != ''){ $title = $('h3:first').text(); document.title = document.title + " | " + $title; $('meta:first').attr('content', $title); } else if($('.panel-heading:first').text() != ''){ $title = $('.panel-heading:first').text(); document.title = document.title + " | " + $title; $('meta:first').attr('content', $title); } }); </script>
This will merge the generated header at the end of your current header. He also sets the description to one value.
You must have a description meta tag as the first meta tag in your title so that it works to set a description meta file. If this is not the case, you can change the $('meta:first') selector to select a description meta tag.
I use bootstrap, so the first title of the panel is my return case: $('.panel-heading:first') , change this to display the corresponding required margin if there are no title tags on the current page.
When all else fails, this script will leave your name value in its current value.
source share