Skip to content

Instantly share code, notes, and snippets.

@ysugimoto
Created October 29, 2012 01:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysugimoto/3970836 to your computer and use it in GitHub Desktop.
Save ysugimoto/3970836 to your computer and use it in GitHub Desktop.
iOS6's handleEvent not works by Function's property
<!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