How do I change page title based on heading? : <p>I would like to change the title of my page based on the name of </p>

<p>for example,
<code>&lt;h1&gt;lorem imsum&lt;h1&gt;</code> 
would set the page title to <code>lorem ipsum</code></p>
