如何禁用Iframe中的所有单击

How To Disable All Clicks in Iframe

本文关键字:单击 何禁用 Iframe      更新时间:2023-09-26

我使用以下代码在Iframe中显示Html内容

var d = $(prentElem).find('#previewEmailTemplateIframe')[0].contentWindow.document;
 d.open(); d.close();
$("body", d).append(htmlPopUpContent);

现在我可以禁用这个iframe中的所有点击事件了。域名没有变化。

经过一些变通后,我将其用于

             x = $(prentElem).find('#' + Iframe).contents();
          $(x).find('body').attr('oncontextmenu', 'return false');

对于MAC机器,强制触摸

         $(x).on('webkitmouseforcedown', function (event) {
                event.preventDefault();
                return false;
            })
            $(x).on('webkitmouseforcewillbegin', function (event) {
                event.preventDefault();
                return false;
            })

对于正常点击禁用

            $(x).click(function (e) {
                e.preventDefault();
                return false;
            });

它看起来不太好,但它解决了我的问题。。。所以,如果有人面临同样的问题,就发布这个!!!!

但是mozilla firefox仍然不允许禁用鼠标中键点击,所以这在那里不起作用!!