Link to home
Start Free TrialLog in
Avatar of Elliott Ward
Elliott Ward

asked on

Links in old ASP pages are getting an extra slash added to them, how may I remove them?

This ASP page I  am supporting has this line in it:

document.write ("<a style='color:#ffffff'id='login' href='https://Default.asp?Type=LogIn' target='_parent'>Login</a>");

However when the link is actual clicked it is changed to:

https://Default.asp/?Type=LogIn

How do I remove that extra slash?
Avatar of Big Monty
Big Monty
Flag of United States of America image

the href code itself is syntactically correct, although you should have a space between the style value and the ID attribute.

i tested out the following code and it worked fine. is this similar to what you have?

<html>
	<body style="background-color:#000;">
		<script type="text/javascript">
			document.write("<a style='color:#ffffff' id='login' href='https://Default.asp?Type=LogIn' target='_parent'>Login</a>");
		</script>
	</body>
</html>

Open in new window

What happens if you type this https://Default.asp?Type=LogIn directly into the browser - does the same thing happen?

If so then you need to look for something in your code that is doing a redirect.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if the desired result was to get an output of

https://Default.asp?Type=LogIn

then the code, syntactically, IS correct. I know because I tested it out :)

as for the format of the url, that is indeed a different matter. There is no need to have the https:// as part of the doamin IF you are accessing a page on the same server. However, if you are going to another URL, then you need to specify a domain as DB noted.

I agree with JulianH, it's probably a redirect issue.
I would still change the code a bit.

First at the top of the page, force https
<%
   If Request.ServerVariables("SERVER_PORT")=80 Then
      Dim strSecureURL
      strSecureURL = "https://"
      strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
      strSecureURL = strSecureURL & Request.ServerVariables("URL")
      Response.Redirect strSecureURL
   End If
%>

Open in new window

Then change the link code to
document.write ("<a style='color:#ffffff'id='login' href='/Default.asp?Type=LogIn' target='_parent'>Login</a>");

Open in new window