Just like when you ask a question on this website, as you type the title in the tab changes to whatever you have typed in the question box. How do you access this?
Asked
Active
Viewed 1,162 times
2
-
Are you talking about autosuggest - http://jqueryui.com/demos/autocomplete/ – Eric Di Bari Aug 15 '12 at 15:01
-
Set the `document.title` field. http://stackoverflow.com/questions/413439/how-to-dynamically-change-a-web-pages-title – samuelesque Aug 15 '12 at 15:04
5 Answers
4
Quick'n'dirty:
document.title = prompt('sup bro ?');
If you don't want a modal input dialog, you need to catch some events for any <input>
box.
document.getElementById('inputBoxId').addEventListener('keypress', function( event ) {
if( event.keyCode === 13 ) { // return ?
document.title = this.value;
}
}, false);
addEventListener
needs to get replaced by attachEvent
for IE<9

jAndy
- 231,737
- 57
- 305
- 359
1
Something like this:
var textbox = document.getElementById('myTextbox')
function setTitle () {
document.title = textbox.value
}
textbox.onkeyup = setTitle
textbox.onchange = setTitle

Abraham
- 20,316
- 7
- 33
- 39
0
You have to make your title tag, in html dynamic, So the title tag which appears as a element of head tag. You have to either use javascript or some server language to set its value.

sushil bharwani
- 29,685
- 30
- 94
- 128
0
Here,
<script language="javascript">
document.title = "The new title goes here.";
</script>
Just add this in your page and try!

Ahmed
- 2,966
- 7
- 42
- 69
0
If you are using a server side scripting like PHP
or ASP
, its quite simple. Just generate a text based on your URL.
For example, if you have a php page mypage.php
, you may use;
<title><?php echo $_GET["title"]; ?></title> //will display page title "MyPage"
if you call your php page like mypage.php?title=MyPage
Not JavaScript, but just for your information.

Alfred
- 21,058
- 61
- 167
- 249