<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Test title</title> <script type="text/javascript"> window.onload = function () { history.replaceState({}, '', window.location + '?state=2'); console.log("Called history.replaceState"); } </script> </head> <body> This page calls history.replaceState() via JS. </body> </html>