Help removing special character(s) from url variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doublestack
    New Member
    • Jul 2008
    • 21

    Help removing special character(s) from url variable

    I am calling a variable from an aspx page (LOGON_USER) into a url and need to remove the special character "\" so the user can be logged in correctly.

    I am using:

    Code:
    <script type="text/javascript">
    location.replace("http://testsite.com:1001/forms/html/testinstance.html?vsuccess=" + "<%=Request.ServerVariables["LOGON_USER"]%>","iframe1");
    </script>
    It pulls the information correctly but I would like to remove the domain and \ from the url. Eg: currently (acct01\sams), would like (sams) or (acct01sams)

    Thanks!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I see no backslash in the url... (a single backslash will automaticly escape the following character or insert the appropriate special character)

    Comment

    • doublestack
      New Member
      • Jul 2008
      • 21

      #3
      Help removing special character(s) from url variable

      The backslash is in the server variable that is called in the URL (LOGON_USER)
      The variable (LOGON_USER) = acct...\.... based on the user accessing this page.
      Eg: http://testsite.com:1001/forms/html/...ss=acct01\sams

      In IE, it replaces the backslash with a square and removes the first s...like this:
      Code:
      http://testsite.com:1001/forms/html/testinstance.html?vsuccess=acct01ams
      I need to know how to remove that and/or the whole "acct01\" part. Thanks!

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by doublestack
        In IE, it replaces the backslash with a square and removes the first s
        that's because \s is a special char. before you pass the variable you need to escape the backslash (you'll probably need to do that on the server).

        Comment

        • doublestack
          New Member
          • Jul 2008
          • 21

          #5
          Help removing special character(s) from url variable

          Is there any other methods of removing/parsing this out, without having to do it on the server side? Was hoping for a possible JavaScript or similar solution

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            the problem is, once you're in Javascript, the string is already parsed. so there's actually no way to alter the original string in Javascript.

            Comment

            • doublestack
              New Member
              • Jul 2008
              • 21

              #7
              Help removing special character(s) from url variable

              I am pulling the data from a wss site using designer on a custom aspx page...since I am only using javascript to redirect the page to a new url using that variable, would it be possible to parse it first? Thanks for your help on this!

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                I don't see any possibility in JS. when you print out the url through ASP you certainly need to urlencode it.

                Comment

                • doublestack
                  New Member
                  • Jul 2008
                  • 21

                  #9
                  Ok, how would I go about doing that before redirecting the page?

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    that depends on how you compose the URL.

                    Comment

                    • doublestack
                      New Member
                      • Jul 2008
                      • 21

                      #11
                      Using the example url I gave previously:
                      Code:
                      ("http://testsite.com:1001/forms/html/testinstance.html?vsuccess=" + "<%=Request.ServerVariables["LOGON_USER"]%>","iframe1");
                      What would be the best way to parse/encode that special character out of the server variable...a little new to this so any suggestions/examples would be appreciated.

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        because I have no idea of ASP I can't tell, but there should be a method/function that does that. (I could be of help if it were PHP...)

                        Comment

                        • doublestack
                          New Member
                          • Jul 2008
                          • 21

                          #13
                          PHP has to be done server side to work right?

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            #14
                            Originally posted by doublestack
                            PHP has to be done server side to work right?
                            yes, as does ASP.

                            ...............

                            Comment

                            • doublestack
                              New Member
                              • Jul 2008
                              • 21

                              #15
                              Thanks for your input and time!

                              Comment

                              Working...