I’m using CSS style display:block and none for hiding a div based on a condition:
If facebook has been blocked display fb_Blockedwizard else display fb_wizard.
When I am loading or refreshing the page the div fb_Blockedwizard is displayed for a few second then the div gets hidden.
I need to hide the div during the load or refresh of the page
Below is the code which I’m using:
<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';
}
Here my 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;
}
Here my 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>
Is
fb_Blockedwizardpart of your layout? If so then give it directly the styledisplay:nonewithin HTML/CSS. Set it todisplay:blockper javascript.