This is a bug, and in fact it exists in some browsers. At least firefox-137, the latest of 2025-05, does. This has been asked repeatedly in stackoverflow.com [1] (2016) [2] (2019) [3] (2021).
To check it, save the code below as old.html, and open it with your browser.
<!DOCTYPE html>
<html>
<head>
<title>Old page</title>
<script>
window.onload = function() {
location.replace('http://example.com');
};
</script>
</head>
<body>
No body.
</body>
</html>