jquery - Updating part of the title tag, but not all of it, or at least a good work around? -



jquery - Updating part of the title tag, but not all of it, or at least a good work around? -

i want have number of notifications in title part of (like facebook does), haven't been able come way of doing this. did few years ago, way did wasn't good, mess , remove wrong parts of sometime. i'm trying come easiest way this.

and value of title dynamic, can't have manually 1 way.

so like:

(8) mysite - home page

then when changes go like: mysite - home page or mysite - userid102

what had done before this:

var got_title = $('title').html(); var find_notifications = got_title.match(/\([0-9]\)\s/); ///look (1-9) if(find_notifications) { var default_title = got_title.split(' ')[1]; } if(!find_notifications) { var default_title = got_title; } $('title').html(update_notification+default_title);

however it's unreliable, worked fine, maintain adding notifications, like:

mysite - home --> (5) mysite - home --> (5)(5)(5)(5)(5)(5) mysite - home

i don't know content of update_notification, maybe can help you:

var got_title = $('title').html(); var default_title = got_title.match(/(\(\d+\)\s)?(.*)/)[2]; $('title').html(update_notification+default_title);

also see example.

jquery html notifications title

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -