Created
October 29, 2012 01:15
-
-
Save ysugimoto/3970836 to your computer and use it in GitHub Desktop.
iOS6's handleEvent not works by Function's property
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>index</title> | |
<meta name="viewport" content="width=device-width; initial-scale=1.0" /> | |
<script> | |
document.addEventListener('DOMContentLoaded', function() { | |
function Klass() { | |
} | |
Klass.handleEvent = function() { | |
alert('Function property'); | |
} | |
Klass.prototype.handleEvent = function() { | |
alert('Interface'); | |
} | |
// Not good | |
document.addEventListener('touchstart', Klass, false); | |
// Good | |
document.addEventListener('touchstart', new Klass, false); | |
}, false); | |
</script> | |
</head> | |
<body> | |
<h1>Click the document.</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment