我使用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