Javascript match part of url, if statement based on result.
Posted
by nick
on Stack Overflow
See other posts from Stack Overflow
or by nick
Published on 2010-06-07T09:27:20Z
Indexed on
2010/06/07
9:32 UTC
Read the original article
Hit count: 173
JavaScript
Here is an example of the url i'm trying to match: http://store.mywebsite.com/folder-1/folder-2/item3423434.aspx
What im trying to match is http: //store.mywebsite.com/folder-1 except that "folder-1" will always be a different value. I can't figure out how to write an if statement for this:
Example (pseudo-code)
if(url contains http://store.mywebsite.com/folder-1)
do this
else if (url contains http://store.mywebsite.com/folder-2)
do something else
etc
© Stack Overflow or respective owner