Click here to Skip to main content
12,298,927 members (51,659 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.9K views
3 bookmarked
Posted

JavaScript Title Changer

, 5 Nov 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
JavaScript code to change your title instantly, i.e., dynamic title

This code changes your title in 4 seconds:

<title></title> 

and put this JavaScript code anywhere between <script> tags:

/* Begin */
var message = new Array();

message[0] = "Welcome to our site";
message[1] = "Here you'll find exactly what you need";
message[2] = "We know how to solve your problems..";

var reps = 1;
var speed = 200;// Set the overall typing speed (larger number = slower action).
var hold = 4 	// set the length of time to display the whole phrase 
		// before retyping (larger number = longer)

// DO NOT EDIT BELOW THIS LINE.
var p = message.length;
var q = 0;
var r = 0;
var C = 0;
var mC = 0;
var s = 0;
var sT = null;

if (reps < 1) {
reps = 1;
}
function setMessage() {
typing = message[mC];
q = typing.length;
r = q + hold;
typeMessage();
}
function typeMessage() {
if (s > r) {
s = 0;
}
if (s > q) {
document.title = ''+ typing +' - - -';
}
else {
document.title = ''+ typing.substr(0,s)+' - - -';
}
if (C < (r * reps)) {
sT = setTimeout("typeMessage()", speed);
C++;
s++;
}
else {
C = 0;
s = 0;
mC++;
if(mC > p - 1) {mC = 0;}
sT = null;
setMessage();
}
}
setMessage();

/* end*/ 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Emerald kweks
Chief Technology Officer Microbold Smart - Systems
Nigeria Nigeria
Passionate about web and applications technology.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160525.2 | Last Updated 5 Nov 2013
Article Copyright 2013 by Emerald kweks
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid