I've following two javascript code snippets written for same purpose but only one is working. Why so?

The Working script is as below:

```
<script language="javascript"> 
    function Redirect(){
      window.location.assign("login.php")
    }
  </script>

<button type="button" class="btn btn-primary" name="cancel" id="cancel" onClick="return Redirect()">Cancel</button>

```

The non-workable code is as follows:

```
<button type="submit" class="btn btn-primary" name="submit" id="submit" value="" onclick="javascript:window.location.href='login.php'">Back</button>

```

But I want the script to be written like the second one only. I can't use first approach though it's working. Can any one please correct the second code snippet and make it workable like first script? Thanks in advance.