以下のコードはうまく機能します。ここに私の問題があります: ウィンドウの URL はリダイレクトされますが、元の URL はブラウザーの履歴に記録されません。
たとえば、「http://example.com/page1」にアクセスすると、ブラウザは「http://example.com/test」にリダイレクトされます。ただし、別の関数で呼び出すことができるように、元の URL (「http://example.com/page1」) をブラウザーの履歴に表示する必要があります。
リダイレクトする前に、ブラウザの履歴にログインするためにアクセスした元の URL を取得する方法はありますか?
<!-- script to enable age verification cookies and ensure people have age checked -->
<script type="text/javascript">
$(document).ready(function(){
if (window.location =="http://example.com/home") {//do nothing
} else {
window.location = "http://example.com/test";
}
});
</script>