Assuming you are talking about this js in browser environment (unlike others like nodejs), Unfortunately I think what you are trying to do isn't possible simply because this is not the way it is supposed to work. Html pages are delivered to the browser via HTTP Protocol, which is a 'stateless' protocol. If you still needed to pass values in between pages, there could be 3 approaches: Session Cookies HTML5 LocalStorage POST the variable in the url and retrieve them in next.html via window objectlocalStorage["key"] = value; // ... in another page ... value = localStorage["key"];