2013-08-23 55 views
0

我試圖將一個類添加到div中,這是在iframe中加上Fancybox iframe。嘗試了幾個小時之後,我無法使其工作。控制檯日誌測試打印出來,所以我不知道我做錯了什麼。它是Fancybox版本1.3.4。無法在Fancybox iframe中添加CSS類

jQuery(".lightbox").fancybox({ 
    'width'  : '100%', 
    'height'  : '90%', 
    'transitionIn' : 'none', 
    'transitionOut': 'none', 
    'type'   : 'iframe', 
    onComplete: function() { 
     jQuery('#fancybox-frame').contents().find('#right_container').addClass('test123'); 
     jQuery('#right_container').addClass('test321'); 
      console.log('test'); 
     } 

這裏的頁面:http://www.rescue3international.com/onlinetraining.php

任何幫助,將不勝感激。謝謝!

回答

0

不,我收到很多錯誤/警告。

因此,在您的頁面中,使用iframe加載內容,然後單擊時,fancybox將加載到另一個iframe中。你可以只有console.log(jQuery('#fancybox-frame'));?我不能這樣做,因爲iframe網址重定向到父網址。

我想,你不能得到iframe的內容,因爲警告顯示瀏覽器顯示的安全錯誤。

Invalid 'X-Frame-Options' header encountered when loading 'http://earthexperience.com/r3/faq': 'GOFORIT' is not a recognized directive. The header will be ignored. 

Blocked a frame with origin "http://www.rescue3international.com" from accessing a frame with origin "http://earthexperience.com". Protocols, domains, and ports must match. 
+0

感謝您的回覆。 console.log('#fancybox-frame'))作品: [iframe#fancybox-frame,context:document,selector:「#fancybox-frame」,constructor:function,init:function,selector:「」 ...] 0:IFRAME#的fancybox幀 上下文:文件 長度:1 選擇: 「#的fancybox幀」 __proto__:對象[0] X框-選項是使得登錄/註銷將在iframe中工作。 而一個框架應該是vimeo播放器。這是它在Chrome控制檯中告訴我的。 謝謝! – user2041974