How to reload a page after the OK click on the Alert Page

后端 未结 10 1451
日久生厌
日久生厌 2021-01-01 18:25

I need to reload the page after the OK button is clicked on the Alert box. I am using the following code for it

alert(\"Successful Message\");
window.locati         


        
相关标签:
10条回答
  • 2021-01-01 18:49

    Interesting that Firefox will stop further processing of JavaScript after the relocate function. Chrome and IE will continue to display any other alerts and then reload the page. Try it:

    <script type="text/javascript">
        alert('foo');
        window.location.reload(true);
        alert('bar');
        window.location.reload(true);
        alert('foobar');
        window.location.reload(true);
    </script>
    
    0 讨论(0)
  • 2021-01-01 18:53

    Try this code..

    IN PHP Code

    echo "<script type='text/javascript'>".
          "alert('Success to add the task to a project.');
           location.reload;".
         "</script>";
    

    IN Javascript

    function refresh()
    {
        alert("click ok to refresh  page");
        location.reload();
    }
    
    0 讨论(0)
  • 2021-01-01 18:56
    alert('Alert For your User!') ? "" : location.reload();
    

    You can write above code in this format also.It seems quite decent

    0 讨论(0)
  • 2021-01-01 18:57

    Bojan Milic answer work in a way but it error out with a message below,

    This can be avoid with,

    function message() 
    {
    alert("Successful message");
    window.location = 'url_Of_Redirected_Page' // i.e. window.location='default.aspx'
    }
    
    0 讨论(0)
提交回复
热议问题