Jump to content

"Dynamic" website titles?

Jeroen1322

Hi guys!

 

You have websites like Hotmail (Outlook) or Omegle or whatever and and when something happends like you get a new email or somebody typed something the title of the website changes to like Hotmail (1) Or with Omegle it even moves.

 

How can you do this? If i make a website the title that is displayed on the tab is the name between the <title>tags</title>. 

 

Thanks! :)

[CPU: AMD FX-6100 @3.3GHz ] [MoBo: Asrock 970 Extreme4] [GPU: Gigabyte 770 OC ] [RAM: 8GB] [sSD: 64gb for OS] [PSU: 550Watt Be Quiet!] [HDD: 1TB] [CPU cooler: Be Quiet! Shadow Rock Pro Sr1]  -Did i solve your question/problem? Please click 'Marked Solved'-

Link to comment
Share on other sites

Link to post
Share on other sites

Hi guys!

 

You have websites like Hotmail (Outlook) or Omegle or whatever and and when something happends like you get a new email or somebody typed something the title of the website changes to like Hotmail (1) Or with Omegle it even moves.

 

How can you do this? If i make a website the title that is displayed on the tab is the name between the <title>tags</title>. 

 

Thanks! :)

Just JS/PHP change the thing inside the title badge when an event triggers it ;)

"Unofficially Official" Leading Scientific Research and Development Officer of the Official Star Citizen LTT Conglomerate | Reaper Squad, Idris Captain | 1x Aurora LN


Game developer, AI researcher, Developing the UOLTT mobile apps


G SIX [My Mac Pro G5 CaseMod Thread]

Link to comment
Share on other sites

Link to post
Share on other sites

Just JS/PHP change the thing inside the title badge when an event triggers it ;)

So they have JS code between the <title> tags and like an if/else statement so if something happens then change this code that is the title?

[CPU: AMD FX-6100 @3.3GHz ] [MoBo: Asrock 970 Extreme4] [GPU: Gigabyte 770 OC ] [RAM: 8GB] [sSD: 64gb for OS] [PSU: 550Watt Be Quiet!] [HDD: 1TB] [CPU cooler: Be Quiet! Shadow Rock Pro Sr1]  -Did i solve your question/problem? Please click 'Marked Solved'-

Link to comment
Share on other sites

Link to post
Share on other sites

So they have JS code between the <title> tags and like an if/else statement so if something happens then change this code that is the title?

IDK what they have, but that is what i would do

"Unofficially Official" Leading Scientific Research and Development Officer of the Official Star Citizen LTT Conglomerate | Reaper Squad, Idris Captain | 1x Aurora LN


Game developer, AI researcher, Developing the UOLTT mobile apps


G SIX [My Mac Pro G5 CaseMod Thread]

Link to comment
Share on other sites

Link to post
Share on other sites

You can easily change the page title by finding the title element and modifying the text between it.

var changeTitleText = function(newText){    var titleNode = document.getElementsByTagName('title')[0];    titleNode.innerHTML = newText;}

To change when a user inputs text, just listen to the 'input' event on the text box or textarea:

inputNode.addEventListener('input', function(){    changeTitleText(this.value);}

For title changes based on the number of emails (and updating it when a new email has been received), you'll need to either have a method in your API's endpoint that quickly returns whether or not a user has new/unread emails and the number of new/unread emails and periodically send an AJAX request to check, or poll the server using a feature like WebSockets (not recommended just for this, though).

Link to comment
Share on other sites

Link to post
Share on other sites

You can easily change the page title by finding the title element and modifying the text between it.

var changeTitleText = function(newText){    var titleNode = document.getElementsByTagName('title')[0];    titleNode.innerHTML = newText;}

To change when a user inputs text, just listen to the 'input' event on the text box or textarea:

inputNode.addEventListener('input', function(){    changeTitleText(this.value);}

For title changes based on the number of emails (and updating it when a new email has been received), you'll need to either have a method in your API's endpoint that quickly returns whether or not a user has new/unread emails and the number of new/unread emails and periodically send an AJAX request to check, or poll the server using a feature like WebSockets (not recommended just for this, though).

You don't need to create that function. You can modify document.title in any JavaScript on the page to modify the title. Here is a quick example:

var someBoolean = true;if (someBoolean){    document.title = "Some awesome string!";}
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×