最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why doesn't this code convert the URL to lowercase? - Stack Overflow

programmeradmin1浏览0评论

This is in my 404.shtml file

<script> var oldUrl = window.location.href; var newUrl = oldUrl.toLowerCase; location.href = newUrl; </script>

This is in my 404.shtml file

<script> var oldUrl = window.location.href; var newUrl = oldUrl.toLowerCase; location.href = newUrl; </script>
Share Improve this question asked Feb 22, 2014 at 23:37 user3056010user3056010 131 silver badge3 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I think var newUrl = oldUrl.toLowerCase; should be var newUrl = oldUrl.toLowerCase();, since it is a function.

toLowerCase is a function so needs ():

<script> 
    var oldUrl = window.location.href; 
    var newUrl = oldUrl.toLowerCase(); 
    location.href = newUrl; 
</script>
发布评论

评论列表(0)

  1. 暂无评论