最初隐藏div,样式设置为display:block

时间:2012-08-06 09:50:33

标签: php javascript jquery css

我正在使用CSS样式display:blocknone根据条件隐藏div: 如果Facebook已被屏蔽,则显示fb_Blockedwizard,否则显示fb_wizard

当我加载或刷新页面时,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>

1 个答案:

答案 0 :(得分:1)

fb_Blockedwizard是你布局的一部分吗?如果是这样,那么直接在HTML / CSS中给出样式display:none。将其设置为每个javascript display:block