Created
April 18, 2013 06:33
-
-
Save MarshalW/5410626 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<head> | |
<title>Test</title> | |
<style> | |
body { | |
background-color: darkkhaki; | |
width: 360px; | |
height: 600px; | |
} | |
</style> | |
<script src="jquery-1.9.1.min.js"></script> | |
</head> | |
<body id="content"> | |
<script> | |
$('body').on('touchstart touchmove touchend', function (event) { | |
console.log('>>>>>>>touch ' + event.type); | |
var x = event.originalEvent.touches; | |
console.log("page x: " + event.originalEvent.a); | |
}); | |
$(document).ready(function () { | |
setTimeout(function () { | |
console.log('>>>>>>generate touch:'); | |
var event = document.createEvent('TouchEvent'); | |
event.initUIEvent('touchstart', true, true); | |
// event.view = window; | |
// event.altKey = false; | |
// event.ctrlKey = false; | |
// event.shiftKey = false; | |
// event.metaKey = false; | |
event.a='111'; | |
event.touches = [ | |
{ | |
pageX: 10 | |
} | |
]; | |
var element = document.getElementById('content'); | |
element.dispatchEvent(event); | |
}, 2000); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这个模拟是实现不了的吧 如果要针对坐标的话