简体   繁体   English

仅在函数结果上显示/加载HTML正文

[英]Display / Load HTML Body only on Results of a Function

I am building an application using HTML, Javascript, CSS. 我正在使用HTML,JavaScript,CSS构建应用程序。 When the user opens the app a function will check if the user is already registered. 当用户打开应用程序时,一个功能将检查用户是否已经注册。 If registered then display the welcome screen with some message. 如果已注册,则显示欢迎屏幕并显示一些消息。 If not registered then show a button to register. 如果未注册,则显示一个按钮进行注册。 Now I have tried many things but the HTML page (body) shows the welcome message and also the Registration button when the app is opened. 现在,我尝试了很多事情,但是HTML页面(正文)在打开应用程序时显示了欢迎消息以及“注册”按钮。

<html>
 <head>
  <script>
   function checkuser(){
   //check if user already regsitered
   if yes{ display(welcome) : block}
  else {display(register) : none}
  }
 </script>
</head>
<body onload="checkuser()">
<div id="register">
<button>Register User</button>
</div>
<div id="welcome">
 <p>Welcome</p>
</div>
</body>
</html>

What is happening is on opening the app (before / after registration), both the div are displayed and then after the check the page re-loads and shows correct div . 在打开应用程序时(注册之前/之后),显示了两个div然后在检查后 重新加载页面并显示正确的div I want that the page should hold itself from displaying anything till the check is finished and the function should control which div to display. 我希望页面在显示检查结果之前不显示任何内容,并且该功能应控制要显示的div Any idea what should be done? 知道应该怎么做吗? Thanks. 谢谢。

显示加载图标,直到填充结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM