Skip to content

Instantly share code, notes, and snippets.

@johntron
Last active August 29, 2015 14:01
Show Gist options
  • Save johntron/16aababf50db66b98ea8 to your computer and use it in GitHub Desktop.
Save johntron/16aababf50db66b98ea8 to your computer and use it in GitHub Desktop.
The author of the following code intended "You are on the Home page" to appear in a dialog when the button is clicked. It doesn't work this way. Why not?
<button>Which page am I on?</button>
<script>
var Page = {
title: 'Home',
init: function() {
document.querySelector('button').onclick = function () {
alert('You are on the ' + this.title + ' page');
};
}
};
Page.init();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment