change the window title
๏ปฟ
<p class="lead">This is a pretty easy one liner</p>
<p>But we can make it a bit more complex with jquery and add a <a href='#counter'>counter</a></p>
<p>It is questionable that crawlers and bots will see this so <i>may be</i> bad for SEO.</p>
<pre>document.title = "A Crazy new page title. ๐";</pre>
<h2>Demo</h2>
<p><button onclick='changetitle("A Crazy new page title. ๐");'> Change the window title</button></p>
<script>
function changetitle(title) {
document.title = title;
}
</script>
<pre>
function changetitle(title) {
document.title = title;
}
</pre>
<h2>Demo 2</h2>
<p>Change the window title and add a counter to it</p>
<p><button onclick='changetitlecounter("๐ A Crazy new page title.");'> Change the window title</button></p>
<p>Window Title: <span id='counter'>1</span> : <span id='title'></span></p>
<p><img src='images/window-title-change-example.jpg' alt='window title change example'></p>
<script>
function changetitlecounter(title) {
counter = $("#counter").html();
counter++;
$("#counter").html(counter);
$("#title").html(title);
document.title = counter + " : " + title;
}
</script>
<pre>
function changetitle_counter(title) {
counter = $("#counter").html();
counter++;
$("#counter").html(counter);
document.title = counter + " : " + title;
}
</pre>