2012-04-27 57 views
3

我想在內容前放置徽標/廣告,但有辦法做到這一點,但問題在於他們使用JS顯示/隱藏方法。會發生什麼情況是用戶在觀看徽標/廣告時無法加載內容,這會導致首次爲徽標/廣告等待用戶,然後再加載實際的Flash內容。 所以我在想如果有一種方式可以顯示徽標/廣告,同時閃存內容在後端繼續加載。 我沒有要求加載器繼續出現,直到後端Flash內容完成加載,因爲我發現只有一個腳本能夠使用Jquery這樣做,但它被設計爲使用固定像素,而我的Flash內容是基於%年齡在後臺加載內容時顯示徽標/廣告

現場演示:http://bloghutsbeta.blogspot.com/2012/04/testing-game-content-issue.html

注:對不起提供BlogSpot的鏈接,但的jsfiddle不是生活在阿富汗5KBPS但仍然是一個人的選擇,如果你覺得我失蹤請讓我知道我會編輯它並盡我所能提供儘可能相關的問題^^

相關標記: 按鈕用於收藏夾或模態窗口

<a class="poplight" href="#?w=100%" rel="popup_name"><img alt="play game" class="happybutton" onmouseout="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" src="http://farm5.static.flickr.com/4084/4998558471_27e3985c16_m.jpg" style="opacity: 0.8;" /></a> 

內容設定爲顯示上述沒有按鈕被點擊

<div class="popup_block" id="popup_name"> 
<script type="text/javascript"> 
$(document).ready(function(){ 
    $('a.poplight[href^=#]').click(function() { 
     $('<iframe/>') 
      .attr('frameborder', 0) 
      .attr('allowTransparency', false) 
      .attr('scrolling', 'no') 
      .attr('width', '100%') 
      .attr('height', '98%') 
      .attr('src', 'http://files.cryoffalcon.com/bhgames/dressup/Celebrities/Wizard%20Fashion.html') 
      .appendTo('#popup_name'); 
    }); 
}); 
</script> 
</div> 

CSS直到:

#fade { 
    display: none; 
    background: #000; 
    position: fixed; left: 0; top: 0; 
    width: 100%; height: 100%; 
    opacity: .80; 
    z-index: 9999999; 
} 

.popup_block{ 
    width: 98.95%; height: 98.2%; 
    display: none; 
    padding: 0px; 
    line-height:1em; 
    font-size: 1em; 
    position: fixed; 
    top: 0px; left: 0px; 
    z-index: 999999999; 
    -webkit-box-shadow: 0px 0px 20px #000; 
    -moz-box-shadow: 0px 0px 20px #000; 
    box-shadow: 0px 0px 20px #000; 
    -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
} 
.close { 
    height:20px; 
    float: right; 
    margin: 0 2px 0 0; 
} 

JS(實際上的Jquery )

<script type="text/javascript"> 
$(document).ready(function(){ 

//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').click(function() { 
var popID = $(this).attr('rel'); //Get Popup Name 
var popURL = $(this).attr('href'); //Get Popup href to define size 

//Pull Query & Variables from href URL 
var query= popURL.split('?'); 
var dim= query[1].split('&'); 
var popWidth = dim[0].split('=')[1]; //Gets the first query string value 

//Fade in the Popup and add close button 
$('#' + popID).fadeIn().css({ 'width': Number(popWidth) }).prepend('<a href="#" title="Close It" class="close"><img src="http://files.cryoffalcon.com/bloghuts/images/close%20button.png" alt="Close" width="20" height="20" /></a>'); 

//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css 
var popMargTop = ($('#' + popID).height() + 0)/0; 
var popMargLeft = ($('#' + popID).width() + 0)/0; 

//Apply Margin to Popup 
$('#' + popID).css({ 
'margin-top' : -popMargTop, 
'margin-left' : -popMargLeft 
}); 

//Fade in Background 
$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag. 
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 

return false; 
}); 

//Close Popups and Fade Layer 
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer... 
$('#fade , .popup_block').fadeOut(function() { 
$('#fade, a.close').remove(); 
}); //fade them both out 

return false; 
}); 

}); 

</script> 

回答

0

我想你可以嘗試設置Flash內容的事件來通知內容已經下載(本教程可以幫助你http://www.permadi.com/tutorial/flashjscommand/)。雖然主要內容不接收來自所有內容元素的信號(如果有多個),您可以顯示模式窗口或只隱藏其他內容。