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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.