Basically, if the URL/window.location contains absolutely any variable whatsoever (past domain.com/, of course), I'd like javascript to execute something.
Currently, I have the following jQuery code which only executes when window.location contains the exact wording "#hash", but as stated before I'd like to expand the functionality for all variables.
Edit: Sorry, to clarify, by variable I mean any one of the following examples:
- domain.com/#hash
- domain.com/#hash2
- domain.com/sub/folder
- domain.com/textwithoutahash
Also, if someone knows how to do this in basic Javascript and without the need for the jQuery library, that would be an added bonus!
$(function() {
if ( window.location.href.indexOf('#hash') > -1 ) {
myfunctionhere;
}
});
domain.com/?some=variabletoo?