I want to change between two pages in html with javascript, but when I change with window.location, the code that is after this sentence continues executing.
window.location
You can use jQuery document.ready or you can create custom bind like this one. In case you use jQuery.
$(document).ready(function() { window.location = 'page.html'; });