简体   繁体   中英

Getting current page on HTML

I am a beginner HTML and I am having trouble putting my idea into the right syntax. I have the following HTML snippet:

<div id="footerterms"><span class="mainsmaller"><a href="/privacy.jsp">Privacy</a> | <a href="/terms_of_use.pdf">Terms of Use</a> | <a href="/sitemap.jsp">Site Map</a></span></div>

What I am trying to do is to have them open in a new tab whenever the user is on a specific page. I figured that having a boolean is a fair way to do it. I wrote the code below, but it seems that the syntax is off.

<var showIt=true;>
<% showIt = Request.ServerVariables("URL") == "payment.jsp" %>
    <% if(showIt){ %>
        <div id="footerterms"><span class="mainsmaller"><a href="/privacy.jsp" target="_blank" >Privacy</a> | <a href="/terms_of_use.pdf" target="_blank" >Terms of Use</a> | <a href="/sitemap.jsp" target="_blank" >Site Map</a></span></div>
    <% }else{ %>    
        <div id="footerterms"><span class="mainsmaller"><a href="/privacy.jsp">Privacy</a> | <a href="/terms_of_use.pdf">Terms of Use</a> | <a href="/sitemap.jsp">Site Map</a></span></div>
    <% } %>

You should also wrap '}' in an ASP block and declare the variable properly. About the URL check, you can read this other answer .

<% showIt = Request.ServerVariables("URL") == "theUrlToCheck" %>
<% if(showIt){ %>
    <div ...>...</div>
<% }else{ %>    
    <div ...>...</div>
<% } %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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