javascript - Go back or redirect to url -
i've been using button users navigate page came from, problem is, if user navigates there in new tab or direct link, haven't "been anywhere" before redirected blank page.
is there solution this? i'm thinking navigate if possible, , if not it'll take specific url.
this have far:
<a href="#" onclick="history.go(-1);return false;">go back</a>
how using document.referrer
? it's hack , not recommend since you'll not maintaining post info (if any). if page doesn't need repost data, should work.
<a id="mylink" href="#">go back</a>
class="lang-js prettyprint-override">$('#mylink').click(function () { if (history.length == 0) { document.location = document.referrer; } else { history.go(-1); } });
i must agree schautdollar's comment - message far improve warning.
javascript jquery html
No comments:
Post a Comment