Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.