document.title : Managing page HTML title

document.title=" this is my new title ";
Demo of managing title of a page

Title tag of the web page is one of the important meta tags of a html page.
The keywords used inside this title tag has high relevant for search engine ranking of a site. You can read on title tag keywords at search engine friendly page here.

You can read html title tag here.

The source code for the above demos , first the top one ( by pressing the button )

<html>
<head>
<title></title>
<script type="text/javascript">
function change_title(){
document.title=document.getElementById("t1").value;
}
</script>
</head>
<body>

<form name=f1 method=post>
<input type=text name=t1 id="t1">
<input type=button onClick='change_title()'; value='Change Title'>
</form>

</body>
</html>


Now the code for second example ( without the submit button by using onkeyup event handler)


<html>
<head>
<title>Original title ends</title>
<script type="text/javascript">
function change_title(keyEvent){
//alert(keyEvent);
keyEvent = (keyEvent) ? keyEvent: window.event;
input = (keyEvent.target) ? keyEvent.target :
keyEvent.srcElement;

if(keyEvent.type=="keyup"){

if(input.value){
document.title=document.getElementById("t1").value;
}
}

</script>
</head>
<body>

<form name=f1 method=post>
<input type=text name=t1 id="t1" onkeyup='change_title(event)';>

</form>

</body>
</html>

document Object Getting URL of the page
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    NASIR

    27-11-2013

    HI
    I VANT OFFLINE IN THE SITE
    IF YOU SEND OFFLINE SITE
    TANKS FOR YOU

    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer