Basically I want to check what url the user is on and compare it to a default value and then run a statement
Let’s say my url is https://stackoverflow.com/questions/ask, I’m trying to do this, and it’s not working:
<script type="text/javascript">
if(document.location.href('/questions/ask') > 0)
{
[do this];
}
Thanks for the help(noob question I know)
Give this a try, you are missing the
indexOfmethod.But I believe you should be going off of the window object, I think document is deprecated (but still works).
You also want to check to see if the index is greater than negative one because zero is technically a correct position.