久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Invisible div 檢測 IFrame 內的點擊

Detecting Click Inside IFrame Using Invisible div(使用 Invisible div 檢測 IFrame 內的點擊)
本文介紹了使用 Invisible div 檢測 IFrame 內的點擊的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我瀏覽了這篇文章.使用 JavaScript 檢測點擊進入 Iframe

但是,我仍然看到人們做了類似的事情.請告訴我該怎么做.

一位開發者告訴我:

<塊引用>

您可以在 IFRAME 頂部放置一個透明的 DIV.你的尺寸DIV 大小與 IFRAME 相同或更大.并且以更高的z-index CSS 屬性.

然后當您單擊 IFRAME 時,DIV 會收到該事件.

但由于世界并不完美,現在你失去了點擊的能力在 IFRAME 內.

但我對 div 不太擅長,并希望學習如何做到這一點.謝謝

附言它是關于跨域或異域 Iframeing.

解決方案

如果我明白你在這里問的是什么:

jsFiddle

//在每個 IFRAME 上放置疊加層var W=0, H=0, X=0, Y=0;$(.iframe").each(function(i,el){W = $(el).width();H = $(el).height();X = $(el).position().left;Y = $(el).position().top;$(this).after('

');$(this).next('.overlay').css({寬度:W,高度:H,左:X,頂部:Y});});//跟蹤鼠標位置(覆蓋將阻止點擊 iframe 頁面)無功 mx = 0,我的 = 0;$('.overlay').on('mousemove click',function(e){mx = e.clientX - $(this).position().left;my = e.clientY - $(this).position().top;if(e.type==='click'){alert('點擊:X='+mx+' Y='+my)}});

I went through this post. Detect Click into Iframe using JavaScript

But still, I see people have done similar stuff. Please tell me how do I do this.

One developer told me:

You could put a transparent DIV on top of the IFRAME. You size that DIV to the same size or bigger than the IFRAME. And with a higher z-index CSS property.

Then when you click on the IFRAME, the DIV receives the event.

But as the world is not perfect, now you lost the ability to click inside the IFRAME.

But I am not so good with div's and looking to learn how to do this. Thanks

P.S. It is about Cross Domain or Alien Domain Iframing.

解決方案

If I understand what you are asking here:

jsFiddle

// PLACE OVERLAY OVER EACH IFRAME
var W=0, H=0, X=0, Y=0;
$(".iframe").each(function(i,el){
   W = $(el).width();
   H = $(el).height();
   X = $(el).position().left;
   Y = $(el).position().top;
   $(this).after('<div class="overlay" />');
    $(this).next('.overlay').css({
        width: W,
        height: H,
        left: X,
        top: Y        
    });
});

// TRACK MOUSE POSITIONS (the overlay will prevent clicks on iframe page)
var mx = 0, my = 0;
$('.overlay').on('mousemove click',function(e){
    mx = e.clientX - $(this).position().left;
    my = e.clientY - $(this).position().top;

    if(e.type==='click'){
        alert('clicked at: X='+mx+' Y='+my)
    }        
});

這篇關于使用 Invisible div 檢測 IFrame 內的點擊的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作為類名,因為它是保留的 Cake 2.2.x)
Session is lost after an OAuth redirect(OAuth 重定向后會話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁排序)
CakePHP Shared core for multiple apps(CakePHP 多個應用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯誤:允許的內存大小為 134217728 字節已用盡(嘗試分配 87 字節))
主站蜘蛛池模板: 天天看天天操 | 亚洲视频在线一区 | 欧美在线一区二区三区 | 国产一区二区在线视频 | 有码在线 | 久久久久亚洲精品 | 久久久这里都是精品 | 精品久久久久久亚洲综合网 | 国产亚洲精品精品国产亚洲综合 | 国产精品综合久久 | 久久久成人免费一区二区 | 大象视频一区二区 | 亚洲精品久久久久中文字幕二区 | 欧美精品在线一区二区三区 | www.亚洲区 | 欧美久久一级特黄毛片 | 亚洲成人一区二区 | 日本中出视频 | 国产 欧美 日韩 一区 | 亚洲精品一区二区网址 | 精品无码久久久久久国产 | 午夜婷婷激情 | 亚洲精品乱码久久久久久按摩观 | 九一在线观看 | 日韩精品成人 | 中文久久| 久久国产精品99久久久大便 | 成人做爰9片免费看网站 | 欧美在线视频网 | 午夜视频在线播放 | 免费黄篇 | 91日b| www国产亚洲精品 | av资源网站 | 成人在线中文字幕 | 亚洲 欧美 综合 | 欧美精品一区在线 | 成年人在线观看 | 亚洲视频一区 | 久久国产精品亚洲 | 欧美a在线 |