I think var newUrl = oldUrl.toLowerCase;
should be var newUrl = oldUrl.toLowerCase();
, since it is a function.
Why doesn't this code convert the URL to lowercase?
-
15-10-2022 - |
题
This is in my 404.shtml file
<script> var oldUrl = window.location.href; var newUrl = oldUrl.toLowerCase; location.href = newUrl; </script>
解决方案
其他提示
toLowerCase
is a function so needs ()
:
<script>
var oldUrl = window.location.href;
var newUrl = oldUrl.toLowerCase();
location.href = newUrl;
</script>
不隶属于 StackOverflow