javascript - upon entering/leaving the page append a string in the url. Is this possible? -
is there way append string in url upon leaving/entering?
say default url www.foo.com
then upon entering/leaving, becomes www.foo.com?param=1
without clicking something?
just using javascript.
any appreciated. thanks!
here 1 possible method that. using jquery, , adds parameter on page entry (on page leave, it's kind of pointless; also, trigger on addition first case well) -
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script> $( window ).load(function() { if (! window.location.href.contains("param=0")) { window.location.href = window.location.href+"?param=0"; } }); </script>
Comments
Post a Comment