我使用Windows Store开发(Windows 8)中的HTML/Javascript在IFrame中加载本地HTML文件。我想从Iframe中获取Swipe事件。检测iframe中的滑动手势
我试过这个sample & this。我暂停了包含一个div元素的鼠标滚轮场景。 对于Iframe,它不起作用。
我的代码:
<body>
<iframe id="iframe_Id" src="split.html" style="height:768px; width:1366px;" onload="Load();"></iframe>
</body>
function Load() {
var elt = document.getElementById("iframe_Id");
elt.style.backgroundColor = "#f3f3f3";
var gobj = new MSGesture();
// Defining gesture object for Pen, mouse and touch
gobj.target = elt;
elt.gesture = gobj;
elt.gesture.pointerType = null;
// Creating event listeners for gesture elements
elt.addEventListener("MSPointerDown", onPointerDown, false);
elt.addEventListener("MSGestureTap", onTap, false);
elt.addEventListener("MSGestureHold", onHold, false);
elt.addEventListener("MSGestureChange", onGestureChange, false);
// Mouse Wheel does not generate onPointerUp
elt.addEventListener("MSGestureEnd", onGestureEnd, false);
}
function onPointerDown(e) {
var content = document.getElementById("iframe_Id");
}
我创建功能的所有事件。但是当在我的IFrame中刷卡时,事件不会引发。 我在这里构建。我需要使用Swipe。请帮我解决这个问题。
这真的有必要吗?为什么要寻找新的div而不是身体的刷卡? – WoIIe
@Natuu 我做了你的建议。它不工作。我能够在div上刷卡..但不Iframe – Kumar