2011-09-09 27 views
1

我有一個ul鏈接到圖像和swf文件(橫幅)。點擊鏈接後,Fancybox打開覆蓋圖並顯示圖像/ swf文件。使用Fancybox打開SWF文件時動態更改尺寸

問題是無論swf文件的尺寸如何,Fancybox總是顯示約580 * 390的覆蓋圖。這當然會給swf文件帶來扭曲的視圖。

我一直在擺弄自動縮放和這樣的,沒有結果...... :-(

這是我的代碼:

$("a.fancybox").attr('rel', 'gallery').fancybox({ 
    'transitionIn'  : 'none', 
    'transitionOut'  : 'none', 
    'titlePosition'  : 'inside', 
    'titleFormat'  : function(title, currentArray, currentIndex, currentOpts) { 
     return '<span id="fancybox-title-inside">' + (currentIndex + 1) + '/' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>'; 
    } 
}); 

是否有任何方式的fancybox可以檢測的尺寸swf文件,並確定覆蓋層的尺寸作爲結果?

請注意,我沒有在數據庫中的SWF文件的尺寸或其他 也請注意,圖像和瑞士法郎總是混合在隨機

焦急等待您的回覆!

問候,

中號

回答

0

的解決方案是,如前評論的,顯示在單獨的PHP頁的SWF文件,在其中經由SWFObject的設置的SWF的高度&寬度,然後使用的fancybox的iframe中源設置。在後端將SWF傳遞給此文件,就是這樣!

0

也許你可以使用的fancybox的自動縮放或autodimension選項。正如API page描述:

autoScale true If true, FancyBox is scaled to fit in viewport 
autoDimensions true For inline and ajax views, resizes the view to the element recieves. Make sure it has dimensions otherwise this will give unexpected results 
+0

謝謝,但這些設置不起作用。我的覆蓋保持與上述相同的尺寸。 – maartenmachiels

0

你能不能使用jQuery獲得SWF的尺寸,並將其傳遞到使用寬度和高度選項爲的fancybox文檔中指定的代碼的fancybox。 http://fancybox.net/api

+0

這聽起來像是一個很好的解決方案。如何通過jQuery來確定維度? – maartenmachiels

+0

您需要按照以下方式進行操作: var mySwfWidth = $('#idOfSwf')。width(); var mySwfHeight = $('#idOfSwf')。height(); 然後在您的的fancybox的屬性,你將有: 寬度:mySwfWidth, 高度:mySwfHeight – ScampDoodle

+0

問題是SWF外部加載,而不是內聯。我已經看到,你可以用php(getimagesize($ path_or_url);)找到尺寸,但整個過程似乎很複雜... – maartenmachiels