可以透過JQuery用以下方法來取得iframe中的物件並控制它
$(function() {
$('#abgne_iframe').load(function(){
var $iframe = $(this),
$contents = $iframe.contents();
getContent.find("iframe中的物件").hide();
});
});
控制iframe物件因為有安全性的問題,基本上是不可以跨站執行,如果要跨站使用網路資源,必須透過server端才可以,以php來說可以用 file_get_contents 來取得頁面內容再用iframe來包在頁面中
如果用Colorbox來使用iframe開啟外部網頁,如果是內嵌影片播放頁面如,VideoJS等...,可能會遇到播放器中的fullscreen按鈕無法正常使用,針對此問題,您可以用下列代碼來解決:
$('a.video').colorbox({iframe:true, innerWidth: "720px", innerHeight: "405px", fastIframe:false, onComplete:function(){
$('.cboxIframe').attr({
webkitAllowFullScreen : true,
mozallowfullscreen : true,
allowFullScreen : true
});
}});