Capitalize title page if

I wrote this script to capitalize first letter of title or if URL contains giocatori_ first letters of name until '-' (Giovanni Rossi) but the if it doesn't work.

$(document).ready(function(){
    function capitaliseFirstLetter(string){
        if (/giocatore_/.test(window.location)) {
            var title = document.title;
        subTitle = title.split('-')[0];
        subTitleNext = title.split('-')[1];
        subTitle=subTitle.replace('_',' ');

        subTitle = subTitle.toLowerCase().replace(/b[a-z]/g, function(letter) {
            return letter.toUpperCase();
        })


        document.title = subTitle+' - '+subTitleNext;
    } else {
        return string.charAt(0).toUpperCase() + string.slice(1);
    }
    document.title = capitaliseFirstLetter(document.title);
});

Any suggestion?

Thanks


After looking at another thread: How do I check if string contains substring?

I think you might be missing the i flag from your statement, which makes the match case-insensitive.

if (/giocatore_/i.test(window.location)) {
链接地址: http://www.djcxy.com/p/74108.html

上一篇: Scala高级类型用法

下一篇: 大写标题页如果