警告消息框显示空白页后面


Alert msg box display blank page behind

我在客户端浏览器上显示一个消息框。它工作得很好,但当这个警告消息框弹出时,我看到一个空白页。但是我希望用户总是能看到他浏览的页面并弹出这个消息框。这是我的密码。"if ($ _POST['提交']= ="拯救"){

  $language=$_POST['pbx_lan'];
  if($language!="")
  {
  $query="update `account_detail` set `prompt_language`= '$language' WHERE `org_id`='".$_SESSION['account_id']."'";
  $result = $mysqli->query($query) or die($mysqli->error);

  $_SESSION['check_update'] = "1";
  // setcookie("msg","Language Successfully Updated",time()+5,"/");
  echo '<script>
  confirm("You have selected '.$language.'");
  window.location = "'.SITE_URL.'index.php?view=pbx_prompts."
  </script>';
  // header("location:".SITE_URL."index.php?view=view_service");
  }
  else
  {
  setcookie("err","No Language Selected.Please Select Language",time()+5,"/");
  header("location:".SITE_URL."index.php?view=view_service");
  }
  }` 

调用confirm()时,页面停止加载。当您在页面末尾添加confirm()时,在confirm()显示之前加载页面

<body>
    TEST123
    <script>
        confirm('test');
    </script>
</body>
不是

<body>
    <script>
        confirm('test');
    </script>
    TEST123
</body>

对于你的代码,这意味着

 echo '<script>
  confirm("You have selected '.$language.'");
  window.location = "'.SITE_URL.'index.php?view=pbx_prompts."
  </script>';

必须移动到body标签的底部还要复制所需的if语句,以便仅在必要时执行代码。

body标签底部的完整代码应该是这样的:

if (!empty($language) && $_POST['submit'] == "Save") {
      echo '<script>
         confirm("You have selected '.$language.'");
         window.location = "'.SITE_URL.'index.php?view=pbx_prompts."
      </script>';
}