js .substring and .lastIndexOf methods not working

Results 1 to 3 of 3

Thread: js .substring and .lastIndexOf methods not working

  1. #1
    Join Date
    Dec 1969

    Default js .substring and .lastIndexOf methods not working

    Hi all,<BR>I am attempting to extract a substring from the url by doing the following<BR><BR>&#060;script language=javascript&#062;var str = window.location;<BR>document.write(str.substring(s tr.lastIndexOf("=")))<BR>&#060;/script&#062;<BR><BR>I keep getting the following error:<BR>object does not support this property or method.<BR><BR>Cant figure out why this wont work.<BR>Any ideas?<BR>TIA!<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: js .substring and .lastIndexOf methods not wor

    just to make sure you&#039;re working with a string:<BR><BR>var str = document.location.href<BR><BR>Also, your substring doesn&#039;t look right, think it has more parameters than that...<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Substring use okay...

    When you only give one argument, the result is the substring from first arg position to the end of the string.<BR><BR>And if Oli&#039;s response wasn&#039;t clear:<BR> document.location<BR>is an *OBJECT*. It has several properties. One of the properties is href, which is the string you wanted.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts