Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  113] [ 4]  / answers: 1 / hits: 41103  / 10 Years ago, sat, june 28, 2014, 12:00:00

I currently have this code to check the website URL GET options for a specific ID, but whenever this code is run, I get a weird error: Uncaught TypeError: Undefined is not a function



Here is my code:



<script language=JavaScript>
var familyid = id=8978566;
var corporateid = id=8978565;

if(window.location.indexOf(familyid) === -1)
{
document.write(Family ID not found);
}

</script>


It would be awesome if i could get some guidance on this issue... I couldn't find similar issues using the .indexOf() function


More From » get

 Answers
12

window.location is a Location object, not a string, and indexOf is a String (or Array) method.



If you want to search the query params, try



window.location.search.indexOf(familyId)


or if you want check the whole url,



window.location.toString().indexOf(familyId)

[#70386] Thursday, June 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kayden

Total Points: 546
Total Questions: 102
Total Answers: 95

Location: Virgin Islands (U.S.)
Member since Fri, Mar 4, 2022
2 Years ago
;