The reason this will only work in the browser is because the window.history API is only available in your browser. I'm not quite sure what you mean by "from file". But, as one commenter noted, the problem is where it runs. If, for example, you are doing this in a Node environment and not in a browser, there is no window.history api. Node does not even have a window object.
Since you added the AngularJs flag, it is possible that routing within the application listens for URL changes and will act on them. Angular may have its own way of allowing you to change the url, but I'm not knowledgeable enough to help with this.
source share