FIX: location.pathname Incorrectly Returns Port Number

ID: Q183490


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 4.0, 4.01


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 this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Microsoft Internet Explorer 5.

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Jason Strayer, Microsoft Corporation

Additional query words:

Keywords : kbIE400bug kbIE401bug kbIE500fix
Version : WINDOWS:4.0,4.01
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: November 17, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.