我嘗試創建一個頁面,它在全尺寸上顯示Flash元素,但是當我在較小的屏幕上查看網站時,我想要觸發回退。手動切換SWF對象回退=
這現在不適用於我,因爲瀏覽器支持Flash。
我找不到手動切換回退的方法。
我嘗試創建一個頁面,它在全尺寸上顯示Flash元素,但是當我在較小的屏幕上查看網站時,我想要觸發回退。手動切換SWF對象回退=
這現在不適用於我,因爲瀏覽器支持Flash。
我找不到手動切換回退的方法。
回退不能手動觸發的,但如果一定可以防止SWF加載不符合標準。就你而言,你說過,如果視口符合指定的最小尺寸,則只需嵌入SWF。
如果你試圖加載在初始頁面加載的SWF,只是做這樣的事情:
//Viewport function based on
//http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
function GetViewportDimensions(){
var de = document.documentElement,
b = document.getElementsByTagName('body')[0],
w = window.innerWidth || (de && de.clientWidth) ? de.clientWidth : b.clientWidth,
h = window.innerHeight || (de && de.clientHeight) ? de.clientHeight : b.clientHeight;
return { width: w, height: h };
}
swfobject.addDomLoadEvent(function(){
var actualDimensions = GetViewportDimensions(),
minimumWidth = 600,
minimumHeight = 500;
if(actualDimensions.width >= minimumWidth && actualDimensions.height >= minimumHeight){
swfobject.embedSWF("mymovie.swf", "flashcontent", "550", "400", "9");
} else {
//do nothing, use fallback
}
});
此代碼將只嘗試嵌入SWF如果視口足夠大。如果Flash不存在,swfobject.embedSWF
將會失敗,並且您的備用內容將保留原位。
如果僅用於測試目的,你可以評論這一行:
swfobject.embedSWF("main.swf?v=1", "flashcontent", "972", "1200", "10.1", "expressInstall.swf");
使用2斜槓
// swfobject.embedSWF("main.swf?v=1", "flashcontent", "972", "1200", "10.1", "expressInstall.swf");
更新:
if (swfobject.getQueryParamValue("noflash") != "true")
swfobject.embedSWF("main.swf?v=1", "flashcontent", "972", "1200", "10.1", "expressInstall.swf");
,那麼你可以測試使用一個新的URL:
www.yourwebsite.com/?noflash=true
我在想活的網站。如果該網站在小屏幕上查看,但瀏覽器支持Flash,我寧願顯示圖像而不是Flash。 – andeersg
我已更新帖子,希望有所幫助 –