Lokesh Kakran Lokesh Kakran - 5 months ago 14
Javascript Question

On every time page refreshing F5, i want to redirect on a particular page

After submit a form from AAA.jsp (on the success of ajax it redirect to BBB.jsp). Next time On every Refreshing or F5, i Want it Back to AAA.jsp.
How to? code of BBB.jsp is alike

<script type="text/javascript"> // </script>
<div ng-if="error == ''" class="alert alert-success">
<span class="glyphicon glyphicon-ok-sign"></span> The id is <strong>{{Id}} </strong>..</span> </div>
<div ng-if="error != ''" class="alert alert-warning"> <span class="glyphicon glyphicon-warning-sign"></span> {{error}}. </div>

  • Yes this is possible for that you have to try below

    enter code in controller of BBB.jsp--

    window.onbeforeunload = function(){
      window.setTimeout(function ()  {
                         window.location = 'AAA.jsp';}, 0);  

    window.onbeforeunload = null;

    // necessary to prevent infinite loop, that kills your browser