Knowledge Base

FIX: location.pathname Incorrectly Returns Port Number

Article ID: 183490

Article Last Modified on 10/15/2002


APPLIES TO


This article was previously published under Q183490

SYMPTOMS

The location.pathname property returns a string that incorrectly has the port number appended. This only occurs when used on a page hosted on a Web server port other than 80 or 8080.

For example, location.pathname on a document with the URL "http://testserver:81/stuff/page.htm" incorrectly returns the string "/:81/stuff/page.htm".

RESOLUTION

Look for the existence of the port number in the location.pathname string, and if it exists, remove it. Here is sample code that demonstrates a possible workaround:
<SCRIPT LANGUAGE="VBScript">
  locPath  = location.pathname
  cchColon = InStr(LocPath, ":")
  if (cchColon > 0) then
   cchRealPathStart  = InStr(cchColon, locPath, "/")
   if (cchRealPathStart > 0) Then
      locPath = mid(locPath, cchRealPathStart, Len(locPath))
   end if
  end if
</SCRIPT>
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Internet Explorer 5.

Keywords: kbbug kbfix kbie500fix KB183490