Bugzilla,Mozilla 的问题跟踪器,在执行搜索时有一个漂亮的加载屏幕。在 Ajax 时代,这没什么特别的。不过,他们没有任何脚本就可以做到这一点,我想知道如何做到这一点。
例如:
- 禁用 JavaScript
- 打开以下网址:
https://bugzilla.mozilla.org/buglist.cgi?short_desc=IDL&resolution=---&resolution=DUPLICATE&query_format=advanced&short_desc_type=allwordssubstr
您将获得一个带有动画图像的页面,文本为“正在检索您的错误,请稍候”。以及“Bugzilla 正在考虑您的搜索”的标题。
更新:
这是执行搜索时的整个 DOM。没有元刷新,没有脚本。
<html>
<head>
<title>Bugzilla is pondering your search</title>
</head>
<body>
<div style="margin-top: 15%; text-align: center;">
<center>
<img width="160" height="87" alt=""
src="extensions/BMO/web/images/mozchomp.gif">
</center>
<h1>Please wait while your bugs are retrieved.</h1>
</div>
</body>
</html>
一段时间后,结果页面出现。以前的 HTML 消失了,出现了一个全新的 DOM,包括一个新标题“Bug List”。
所以我的问题是:这究竟是如何工作的?请不要列出替代技术 - 我对加载屏幕根本不感兴趣,但想将这种机制用于完全不同的事情。
最佳答案
如果您查看页面的源代码,您会发现您实际上得到了两个响应,每个响应都有自己的标题
WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY.
--------- =_y97AELt1tHMqcK8D
Content-Type: text/html; charset=UTF-8
<html>
<head>
<title>Bugzilla is pondering your search</title>
</head>
<body>
<div style="margin-top: 15%; text-align: center;">
<center><img src="extensions/BMO/web/images/mozchomp.gif" alt=""
width="160" height="87"></center>
<h1>Please wait while your bugs are retrieved.</h1>
</div>
</body>
</html>
--------- =_y97AELt1tHMqcK8D
Content-Type: text/html; charset=UTF-8
content-disposition: inline; filename="bugs-2011-08-30.html"
Set-Cookie: {data}
Set-Cookie: {data}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bug List</title>
{the rest of the request}
除了 mozilla 之外,我不太确定浏览器对此的支持......
关于html - 如何在没有 JavaScript 的情况下清除已经发送到浏览器的 HTML 内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7243028/