簡體   English   中英

iframe上的jQuery .load添加覆蓋的CSS樣式

[英]jquery .load on iframe add overiding css styles

我嘗試了許多不同的選擇,但似乎沒有任何效果

我的iframe具有很多內聯css樣式,這些樣式具有!important標簽,我想在iframe加載后覆蓋它們

這是我的jQuery和失敗的jsfiddle

http://jsfiddle.net/VJuyR/

$(document).ready(function() {   
    $('<iframe />').load(function(){
          alert('the iframe is done loading');
          $(".poweredBy").css("display", "none");
    });        
});

使用iframe代替<iframe /> ,還使用iframe content ()獲取iframe content然后使用find()您的element例如

$('iframe').load(function(){
      alert('the iframe is done loading');
      $(this).contents().find(".poweredBy").css("display", "none");
});

上面將在same domain 工作,元素很容易訪問。

但是根據同源策略,您將獲得權限拒絕類型錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM