我使用的CSS樣式display:block
和none
隱藏基於條件的div
: 如果Facebook已經封鎖顯示fb_Blockedwizard
其他顯示fb_wizard
。最初隱藏的div與樣式設置爲display:block
當我加載或刷新頁面時,div fb_Blockedwizard
會顯示幾秒鐘,然後隱藏div
。
我需要隱藏的頁面
下面的負載或刷新過程中div
是我使用的代碼:
<script>
$(document).ready(function() {
hideFbBlockedwizard();
hidefbwizard();
var callbackOnSuccess = function(src) {
hideFbBlockedwizard();
showwizard();
return false;
};
var callbackOnFailure = function(src) {
hidefbwizard();
showFbBlockedwizard();
};
checkAvailability("http://www.facebook.com/favicon.ico",
callbackOnSuccess,callbackOnFailure);
});
function showFbBlockedwizard() {
document.getElementById('fb_Blockedwizard').style.display='block';
document.getElementById('fade').style.display='block';
}
function hideFbBlockedwizard() {
document.getElementById('fb_Blockedwizard').style.display='none';
document.getElementById('fade').style.display='none';
}
function checkAvailability(src, callbackSuccess, callbackFailure) {
$("<img/>").attr("src", src).load(function() {
callbackSuccess(src);
}).error(function() {
callbackFailure(src);
});
}
function showwizard() {
document.getElementById('fb_Blockedwizard').style.display='none';
document.getElementById('fb_wizard').style.display='block';
document.getElementById('fade').style.display='block';
}
這裏我的CSS:
.white_content {
/*display: none;*/
display:none;
position: absolute;
top: 25%;
left: 25%;
width: 46%;
height: 37%;
padding: 16px;
border: 16px solid #999;
background-color: white;
z-index:1002;
overflow: auto;
}
.white_content1 {
display:none;
position: absolute;
top: 13%;
left: 18%;
width: 60%;
height: 63%;
padding: 16px;
border: 16px solid #999;
background-color: white;
z-index:1002;
overflow: auto;
}
這裏我的PHP:
<div id="fb_wizard" class="white_content">
<?php include 'fb_blocked.php'; ?>
</div>
<div id="fb_Blockedwizard" class="white_content1">
<?php include 'fb_blocked_email.php'; ?> </div>
在html中設置blocks樣式爲none,那麼它不會出現在js到達它之前 – 2012-08-06 09:53:19
@Dagon:我設置了display:none;在css – user1578849 2012-08-06 09:57:27