javascript - Loop on back button after re-direction with querystring -
the problem:
i need start url query string containing url of second page - http://www.firsturl.com/?http://www.secondurl.com
. on target page of first url, query string parsed extract second url , browser re-directed second url. done on $(document).ready
it's automatic. works fine, of course falls in hole if user hits button on second url. here's basic code:
$(document).ready(function() { var s = location.search; if(s != '') { var split = s.split('?'); var loc = split[1].replace('?', ''); location.href = '' + loc + ''; } else { //do else on target page.. } });
i've tried creating conditional case where, if referrer 2nd url (loc
in code above), re-direction doesn't execute, seems in case of re-direction, button doesn't return referrer.
i have client side - have no access server.
is there way prevent re-direction triggering on button click? thanks.
once hit second page, set cookie in browser indicating second page has been visited. in first page, before doing redirection check whether cookie not present.
instructions on setting cookie:
<script type="text/javascript"> document.cookie="secondpagevisited=43yj0u3jt;path=/"; //execute line in head of second page. </script>
in first page, check cookie presence:
<script type="text/javascript"> if(document.cookie.indexof("secondpagevisited=43yj0u3jt")==-1){ /*do redirection here*/ } </script>
edit: assuming control first page , not second page, try this:
<script type="text/javascript"> if(document.cookie.indexof("secondpagevisited=43yj0u3jt")==-1){ document.cookie="secondpagevisited=43yj0u3jt;path=/"; /*do redirection here*/ } </script>
Comments
Post a Comment