TrulyXax TrulyXax - 7 months ago 30
HTML Question

Check if there's any string after a character

I want to find out, how can i see if there's any character/string after a specific string part from a string. My question sounds ambiguous but here's my real example:

I can have 2 urls :
or http://domain/classAdd?ItemId=

I want to put a condition in HTML regarding the url, to have specific header on my site.
How can i check if the url has a itemId or not?

At moment i'm getting only :

location.indexOf('classAdd?itemId=') == -1
I tried to verify the length but doesn't work. I searched a lot but i didn't find anything to answer my question, only how to get Specific string from a string. My Id is dynamic and the substring won't work

Thank you guys.


check if this

window.location.href.substring(window.location.href.indexOf('classAdd?itemId=') + 16)

gives you the itemId