EDIT: Seems I describe my problem to complicated: My Question below is: WHY does my shorthand code only work when my input-variable contains '=' and NOT when it doesn't ?
I retrieve the variable with this code:
var hash = getParameterByName('find')
I have recently rebuilt the entire site and by that removed many pages which now results in 404-errors from old external links. I catch those 404-links and convert them into 301-redirects in order to maintain backward compability (Using web.config)
For example the 301-error-catch sends me this:
www.sitename.com?find=find.aspx?f=something
Where as regular referal-links sends me this:
www.sitename.com?find=something
NOTE! the difference after '?' in the PARAMETERS sent to my page. I need to strip everything before the last '='-character.
NOTE! that the Parameter (from 301-error) contains the link to a non-existing page: "find.aspx?". IF the parameter-variable does NOT contain '=' - nothing is to be done.
my latest try is:
var hashtag = getParameterByName('find')
var findParam = hashtag.indexOf('=') ? findParam.split('=')[1] : getParameterByName('find');
i have also tried this:
var hashtag = getParameterByName('find')
var findParam = hashtag.indexOf('=') ? findParam.split('=')[1] : hashtag;
The split part of the shorthand code, actually works. IF hashtag.indexOf returns >0 it works, BUT if it returns -1 I get 'undefined' as result. How Come ?
I would think that by using the shortcode I would be able to clean up the search parameter quite nicely. But I cannot figure out how I go wrong here?