RSS

Change the title of an HTML/Web Page – dynamically

01 Mar

Here is a simple way by which you can dynamically change the title of the browser window (or an HTML page). If the user is entered a wrong username , then you may want to change the title of the html page as per the buisiness people suggested.

Below is the sample code, your user can change the title of the browser window when clicking on the Login button. Function validateUserCredentials() in the following code uses the “Title” property of document object to change the title of the browser window.

<html>
<head><title>Welcome to My Site:</title></head>
<body>
<form action=”/validateUser” method=”post” name=”loginForm”>
<B>Enter Title for the window:</B>
<input type=”text” id=”username”/>
<input input=”text” id=”password”/>
<input input=”button” value=”Change Title” onclick=”javascript:validateUserCredentials()”>
</form>
<script type=”text/javascript”>
function validateUserCredentials(){
if(username == “” && password == “”){
document.title = “Error.Please enter username and password”;
}
}
</script>
</body>
/html>

Nice Javascript tutorial URl : http://www.tizag.com/javascriptT/javascriptsyntax.php

Happy Coding!.

Get glued to know more updates.

Have a nice day 🙂

Advertisements
 
Leave a comment

Posted by on March 1, 2013 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: