Dynamically change the Title bar using javascript / jQuery
The following example will teach you to change your title bar text dynamically, for example in facebook, linkedin and etc website are shown, new updates count in title bar. If you want to do this same on your website, grab the following code.Notes
Your HTML page should contain title tag already, then only we can access the title bar and change the value dynamically.
Example:
JavaScript
document.title="Title Bar Value";
jQuery
$('title').html("Title Bar Value");
Example Program
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>Hi</title>
<script>
var const_titleflg=0;
var const_title=$('title').html();
$(document).ready(function(){
setInterval(function(){chgtitle();},1000);
});
function chgtitle()
{
const_titleflg++;
$('title').html("("+const_titleflg+") "+const_title);
}
</script>
Output
See the output on this window Title bar the count will increase.
0 comments:
Post a Comment