Skip to content

Instantly share code, notes, and snippets.

@tuhinpal
Created October 7, 2021 17:48
Show Gist options
  • Save tuhinpal/5dbbec1dcce53b36a683ee5e0c006d11 to your computer and use it in GitHub Desktop.
Save tuhinpal/5dbbec1dcce53b36a683ee5e0c006d11 to your computer and use it in GitHub Desktop.
Change route without refresh
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Route</title>
</head>
<body>
<button>Click to change</button>
</body>
<script>
document.querySelector('button').addEventListener('click', function () {
window.history.pushState(null, null, "/two");
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment