有什么方法可以停止使用 HTML 呈现当前页面

is there are any way to stop rendering current page using HTML

本文关键字:HTML 当前页 方法 什么      更新时间:2023-09-26

我想停止渲染页面并在用户的浏览器未启用或不支持JavaScript时退出, 我想要它就像 exit() 在 PHP 中的工作方式一样。可以通过HTML吗?

你可以这样做:

<noscript>
    <style type="text/css">body { display: none; } </style>
    <meta http-equiv="refresh" content="0; url=http://redirectpage.com/">
</noscript>

技术上是错误的,但有一些浏览器支持。

   <noscript>
      <meta http-equiv="refresh" content="0;url=noscript.html">
    </noscript>

不,这是不可能的。但是,您可以做的是添加一个样式表,在<noscript>标签内清空页面:

<noscript>
<style>
* { display: none; }
</style>
</noscript>

当然,这会隐藏一切;而不仅仅是页面后面发生的事情。

另一个非常常见的选项是将no-js CSS 类添加到 <body> 标记中,您可以使用 JavaScript 尽早删除该类。也就是说,您可以正确创建CSS规则以根据该类的(不存在)来显示/隐藏元素。

以下是使用 noscript 标签的方法:

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" >
        //  [whatever JS is appropriate]
        </script>
        <noscript>
              <!-- Browser doesn't support JavaScript, so go elsewhere -->
              <meta http-equiv="refresh" content="0;url=http://some.other-website.com/"> 
        </noscript>
    </head>
    <body>
        .... The rest of the HTML body
    </body>
</html>

这仅适用于HTML5的

部分。
我认为最好

将ThiefMaster和Dagon的概念一起使用,作为后备支持