2016-04-29 41 views
0

我顯示HTML內容的iframe中使用下面的代碼如何禁用所有點擊中的iFrame

變種d = $(prentElem).find( '#previewEmailTemplateIframe')[0] .contentWindow.document; d.open(); d.close(); $(「body」,d).append(htmlPopUpContent);

現在我可以禁用此iframe中的所有點擊事件。域名沒有變化。

回答

1
after some workaround i got this to work 

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

for MAC machines force touch 

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

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

      For normal click disable 

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

    It does not look good but it solved my issue...so posting this if anybody faces the same !!!! 

But still mozilla firefox does not allow the middle mouse button click to be disabled so this wont work there!! 
相關問題