indexOf

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • d.schulz81@gmx.net

    indexOf

    i am getting the error "indexOf is not a function" when calling
    URi.indexOf('?' )

    the code:

    function removeFromURL(U Ri, parameter)

    {
    var regexp, path, params, qStart = URi.indexOf('?' ) + 1;
    if (qStart == 0 || qStart == URi.length-1) return URi;
    regexp = new RegExp("(" + parameter + "=[^&]+(&)?)");
    return URi.substring(0 ,qStart) +
    URi.substring(q Start).replace( regexp,'').repl ace(/&$/,'');
    }

    Thanks a lot Dennis

  • Martin Kurz

    #2
    Re: indexOf

    d.schulz81@gmx. net schrieb:[color=blue]
    > i am getting the error "indexOf is not a function" when calling
    > URi.indexOf('?' )
    >
    > the code:
    >
    > function removeFromURL(U Ri, parameter)
    >
    > {
    > var regexp, path, params, qStart = URi.indexOf('?' ) + 1;
    > if (qStart == 0 || qStart == URi.length-1) return URi;
    > regexp = new RegExp("(" + parameter + "=[^&]+(&)?)");
    > return URi.substring(0 ,qStart) +
    > URi.substring(q Start).replace( regexp,'').repl ace(/&$/,'');
    > }
    >
    > Thanks a lot Dennis
    >[/color]

    How are you calling the function? Tested with IE6 and Firefox 1.0.4 withou problems.

    Comment

    • Ivo

      #3
      Re: indexOf

      <d.schulz81@gmx .net> wrote[color=blue]
      > i am getting the error "indexOf is not a function" when calling
      > URi.indexOf('?' )
      >
      > function removeFromURL(U Ri, parameter)
      > {
      > var regexp, path, params, qStart = URi.indexOf('?' ) + 1;[/color]

      You don't say what URi is or should be, so we can only guess. Have you
      actually checked that what is passed to the function is a string, as you
      expect it to be, by the looks of it? Do put an alert( typeof URi ) just
      before the call to indexOf and see.

      hth
      ivo


      Comment

      Working...