简体   繁体   中英

How to reload page after script on Javascript?

I'm a newbee in javascript and i need to refresh page when script is done:

  <script type="text/javascript">
    function validateForm() {
      var x = document.forms["myForm"]["Hostname"].value;
      if (x == "" || x == null) {
        alert("Name must be filled out");
        return document.location.reload(true);
      }
    }
    </script>

But i don't understand how to make it work.

try it

 window.location.reload(true);

<script type="text/javascript">
function validateForm() {
  var x = document.forms["myForm"]["Hostname"].value;
  if (x == "" || x == null) {
    alert("Please specify a FQDN of your host");
    window.location.reload(true);
    return false;
 </script>

This one works fine. Thanks to all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM