Javascript/Jquery/PHP加载页面-如何?

Javascript/Jquery/PHP加载页面-如何?,javascript,php,jquery,html,events,Javascript,Php,Jquery,Html,Events,我有一个网站,有很多元素,加载速度很慢。我一直在寻找一种方法来创建一个指定页面正在加载的加载页面,因为这比一个白色页面更令人愉快 一个理想的例子是 我四处寻找,但建议的例子似乎都不起作用,或者我只是把它们放错了地方 我创建了这个div: <div id="loading" style="width: 100%; height: 100%; background: black; background-attachment: fixed; background-position: to

我有一个网站,有很多元素,加载速度很慢。我一直在寻找一种方法来创建一个指定页面正在加载的加载页面,因为这比一个白色页面更令人愉快

一个理想的例子是

我四处寻找,但建议的例子似乎都不起作用,或者我只是把它们放错了地方

我创建了这个div:

<div id="loading" style="width: 100%;
 height: 100%;
 background: black;
 background-attachment: fixed;
 background-position: top;
 background-size: 100% 100%;
 position: absolute;
 color: white;">Loading! Please calm down guy...</div> 
加载!请冷静点,伙计。。。
我将使用它作为加载页面,并使用此脚本禁用它

<script type="text/javascript">
document.getElementById("loading").style.display = "none";
</script>

document.getElementById(“加载”).style.display=“无”;
然而,当我实现这一点时,它仍然给了我一个白色屏幕,我看到“加载”div在加载整个站点前几毫秒短暂闪烁。我不认为服务器很慢,因为ping是正常的,加载速度很快

谁能提供任何解决方案

这是当前的index.php文件:

<div id="loading" style="width: 100%;
height: 100%;
background: black;
background-attachment: fixed;
background-position: top;
background-size: 100% 100%;
position: absolute;
color: white;">Loading! Please calm down guy...</div>
<?php

header('X-Frame-Options: DENY'); 

$init=true;
include './inc/start.php';
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $settings['title'].' - '.$settings['description']; ?></title>
<meta name="Keywords" content=“Dogecoin, Dice, Bets, Betting”>
<meta name="Description" content=“Exclusive Dogecoin Dice Site - 50% of ALL profits go back into Dogecoin development. In association with forum CryptoBoard.org.”>
<link rel="shortcut icon" href="./favicon.ico">
<link rel="stylesheet" type="text/css" href="themes/<?php echo $settings['activeTheme']; ?>/main.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="content/ext/msgbox/Scripts/jquery.msgBox.js"></script>
<link rel="stylesheet" type="text/css" href="content/ext/msgbox/Styles/msgBoxLight.css">
<script type="text/javascript" src="content/ext/qtip/jquery.qtip.min.js"></script>
<link rel="stylesheet" type="text/css" href="content/ext/qtip/jquery.qtip.min.css">
<script type="text/javascript" src="js/colors.js"></script>    
<?php include './js/includer.php'; ?>
</head>
<body>
<?php include './themes/'.$settings['activeTheme'].'/frontpage.php'; ?>
<!-- _COINTOLI_IDENTIFIER_2_ -->
</body>
</html>
<?php include './inc/end.php'; ?>
<script type="text/javascript">
document.getElementById("loading").style.display = "none";
</script>
加载!请冷静点,伙计。。。
document.getElementById(“加载”).style.display=“无”;

谢谢。

问题在于服务器生成页面所需的时间,在服务器将内容发送到浏览器之前,浏览器无法显示任何内容。服务器生成页面上的内容大约需要6秒,这意味着一些缓慢的查询

您尝试使用的加载栏仅适用于页面上有大量需要加载的对象的情况,例如大量大型图像。实际的HTML会很快发送到浏览器,但加载大型图像是单独完成的,需要时间。但是您的问题不是这样的,页面的HTML需要很长时间才能生成,服务器在生成完整页面之前不会向浏览器发送任何HTML

有几件事你可以试试。第一个是确定需要很长时间才能加载的查询并对其进行优化(我先试试这个)。第二种方法是只加载页面的框架,然后使用Ajax加载内容


第三种方法是不加载页面的所有内容,而是在HTML准备就绪时将其逐点回显到浏览器。根据页面的加载方式,我假设您将所有内容存储到一个变量中,并在准备就绪后将其回显到页面。这很简单,只需回显内容,然后在内容准备就绪时一点一点地回显,而不是将其存储在变量中。

uberdice.com不会为me@Duffmaster33加载但不加载。你能给我举一个例子说明你对后两个选项的意思吗?这将有助于你选择第二个选项-这将有助于你选择第三个选项-