Jump to content

alternate the <title> between original and new title


jason310771

Recommended Posts

Just changing document.title should change the title.

 

To make it switch between two different titles over and over you could use setInterval. Something like:

 

<html>
<head>
	<title>Original</title>
</head>
<body>
	<script language="javascript">
	var originalTitle = document.title;
	var newTitle = "You have a message";

	function toggleTitle()
	{
		if(document.title == originalTitle)
			document.title = newTitle;
		else
			document.title = originalTitle;
	}

	var interval = setInterval("toggleTitle()", 1000);

	// clearInterval(interval); call this to stop it toggling the title
	</script>
</body>
</html>

Link to comment
Share on other sites

You could use AJAX to do that. Have it fetch the output of a PHP script that outputs how many messages a user has and then display that. Just have it on an interval of a few seconds and it will check without the user needing to refresh.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.