经典 ASP 流控制的替代方法

Alternative to Classic ASP flow control

本文关键字:方法 ASP 流控制 经典      更新时间:2023-09-26

我正试图摆脱经典ASP。 我已经开发了替代技术来处理HTML/JavaScript中的所有内容。 但是,我仍然需要一些方法来替换以下内容:

<% if this then %>
    <div>Wow.  This.  Totally this.  Isn't this great?</div>
<% else %>
    <div>You're really missing out on this.</div>
<% end if %>

有没有办法在纯HTML/JavaScript中完成条件分支/条件代码?

客户端脚本的 document.writeln:

<html>
<head>
</head>
<body>
    <br />Some html code before<br /><br />
    <script language="javascript">
        var This = true;
        if(This){
            document.writeln("<div>Wow.  This.  Totally this.  Isn't this great?</div>");
        }
        else{
            document.writeln("<div>You're really missing out on this.</div>");
        }
    </script>
    <br />Some html code after<br /><br />
    <script language="javascript">
        var This = false;
        if(This){
            document.writeln("<div>Wow.  This.  Totally this.  Isn't this great?</div>");
        }
        else{
            document.writeln("<div>You're really missing out on this.</div>");
        }
    </script>
    <br />Some other html code after<br /><br />
</body>

注意:在您的示例中,您使用了"this",我使用了"this","this"在javascript中是一个保留字