Removing http:// prefix from ASP loaded URL [close

2019-08-30 17:59发布

问题:

My page here has advertisers' URLs listed in full, but I'm not sure how to remove the http:// prefix.

Here's the Code:

 <% if instr("abc"&rsAdvert("WebAddress"),"http:")>0 then
     shttp=""
 else
     shttp="http://" 
 %>
 <li class="weblink"> 
   | <a onclick="pageTracker._trackPageview('/TOP_FULL_ADVERT_WEBSITE/<%=shttp%><%=rsAdvert("WebAddress")%>');"
        href='<%=shttp%><%=rsAdvert("WebAddress")%>'
        target='_blank' rel='nofollow'>
    <%=rsAdvert("WebAddress")%></a></li>
<% end if %>

Any ideas would be great.

回答1:

Have you tried

var url = "your url";
url = url.replace("http://", "");


回答2:

You need to change this bit of your code:

<a href="url">text</a>
              ^^^^

You link looks like this:

<a 
    onclick="pageTracker._trackPageview('/TOP_FULL_ADVERT_WEBSITE/<%=shttp%><%=rsAdvert("WebAddress")%>');" 
    href='<%=shttp%><%=rsAdvert("WebAddress")%>' 
    target='_blank' 
    rel='nofollow'>
    <%=rsAdvert("WebAddress")%>
</a>

so you need to chnage the bit just before the </a>, specifically this bit at the end

><%=rsAdvert("WebAddress")%></a>
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

to some variable which does not include the http://

this might work, not sure of classic asp syntax

 ><%=rsAdvert("WebAddress").replace("http://", "")%></a>