function myFunction() {
alert(window[title]);
}
myFunction();
I'm expecting to this see the html the title page.
function myFunction() {
alert(window[title]);
}
myFunction();
I'm expecting to this see the html the title page.
First off, title doesn't belong to window. It belongs to document.
Secondly, you've mixed dot notation and array indexer notation, you either need:
alert(document['title']);
Or:
alert(document.title);
Unless, of course, you have a variable called title that holds the string 'title', in which case it would look something like:
var title = 'title';
alert(document[title]);
function myFunction() {
alert(document.title);
}
First off, window[title] will make javascript look for the undeclared variable title; you probably meant window['title']. Second you want document.title