wap手机端解决返回上一页,js

时间:2022-06-30 05:22:09

<input id="hd_referrer" type="hidden" />
                <a href="javascript:void(0)" onclick="referurl(); ">返回 </a>
                <script>
                    $(function () {
                        $("#hd_referrer").val(document.referrer);
                    });

function referurl() {
                        var ref = $("#hd_referrer").val();
                        if (ref != "" && ref != "undefined") {
                            location.href = ref;
                        }
                        else {
                            location.href = history.back(-1);
                        }
                    }
                </script>