如何更改HTML文本区域的默认语言和字体,并禁用其他语言和字体?(how can i change

2019-09-21 15:43发布

我有一个评论框(textarea的)。我想先更改文本区域和默认字体的默认语言无客户端能够更改语言或字体。 http://www.haveeru.com.mv/dhivehi/business/126135去这个链接,点击发表评论按钮below.a textarea的将appear.it是到底我希望do.same languge(迪维希文)相同的字体。我想在很多ways.but它使用英语的start.thank你。

Answer 1:

他们正在用自己的字体,你希望看到什么样的字体/大小/颜色有人使用看看每次view-source ,在这种情况下,CSS

例如:

@charset "utf-8";
@font-face {
    font-family: "MV Waheed";
    src: local("MV Waheed"), url(/dhivehi/fonts/mv_waheed.otf) format("opentype");
}
@font-face {
    font-family: "MV Faseyha";
    src: local("MV Faseyha"), url(/dhivehi/fonts/mv_faseyha.otf) format("opentype");
} 

或Javascript扩展

(function ($) {
    $.fn.thaana = function (options) {
        var settings = {
            keyboard: 'phonetic'
        };
        return this.each(function () {
            if (options) {
                $.extend(settings, options);
            }
            var keyboards = {
                'phonetic': {
                    33: '!',
                    34: '"',
                    35: '#',
                    36: '$',
                    37: '%',
                    38: '&',
                    39: '\'',
                    40: ')',
                    41: '(',
                    42: '*',
                    43: '+',
                    44: '،',
                    45: '-',
                    46: '.',
                    47: '/',
                    58: ':',
                    59: '؛',
                    60: '>',
                    61: '=',
                    62: '<',
                    63: '؟',
                    64: '@',
                    65: 'ާ',
                    66: 'ޞ',
                    67: 'ޝ',
                    68: 'ޑ',
                    69: 'ޭ',
                    70: 'ﷲ',
                    71: 'ޣ',
                    72: 'ޙ',
                    73: 'ީ',
                    74: 'ޛ',
                    75: 'ޚ',
                    76: 'ޅ',
                    77: 'ޟ',
                    78: 'ޏ',
                    79: 'ޯ',
                    80: '÷',
                    81: 'ޤ',
                    82: 'ޜ',
                    83: 'ށ',
                    84: 'ޓ',
                    85: 'ޫ',
                    86: 'ޥ',
                    87: 'ޢ',
                    88: 'ޘ',
                    89: 'ޠ',
                    90: 'ޡ',
                    91: ']',
                    92: '\\',
                    93: '[',
                    94: '^',
                    95: '_',
                    96: '`',
                    97: 'ަ',
                    98: 'ބ',
                    99: 'ޗ',
                    100: 'ދ',
                    101: 'ެ',
                    102: 'ފ',
                    103: 'ގ',
                    104: 'ހ',
                    105: 'ި',
                    106: 'ޖ',
                    107: 'ކ',
                    108: 'ލ',
                    109: 'މ',
                    110: 'ނ',
                    111: 'ޮ',
                    112: 'ޕ',
                    113: 'ް',
                    114: 'ރ',
                    115: 'ސ',
                    116: 'ތ',
                    117: 'ު',
                    118: 'ވ',
                    119: 'އ',
                    120: '×',
                    121: 'ޔ',
                    122: 'ޒ',
                    123: '}',
                    124: '|',
                    125: '{',
                    126: '~'
                },
                'typewriter': {
                    33: '!',
                    34: '؛',
                    35: '#',
                    36: '$',
                    37: '%',
                    38: '&',
                    39: 'ﷲ',
                    40: ')',
                    41: '(',
                    42: '*',
                    43: '+',
                    44: 'ށ',
                    45: '-',
                    46: 'ޓ',
                    47: 'ޯ',
                    58: 'ޡ',
                    59: 'ފ',
                    60: '\\',
                    61: '=',
                    62: 'ޞ',
                    63: '؟',
                    64: '@',
                    65: '<',
                    66: 'ޟ',
                    67: 'ޏ',
                    68: '.',
                    69: '“',
                    70: '،',
                    71: '"',
                    72: 'ޥ',
                    73: 'ޣ',
                    74: 'ޢ',
                    75: 'ޘ',
                    76: 'ޚ',
                    77: 'ޝ',
                    78: 'ޛ',
                    79: 'ޠ',
                    80: 'ޙ',
                    81: '×',
                    82: '/',
                    83: '>',
                    84: ':',
                    85: 'ޜ',
                    86: 'ޗ',
                    87: '’',
                    88: 'ޕ',
                    89: 'ޤ',
                    90: 'ޖ',
                    91: 'ލ',
                    92: ']',
                    93: '[',
                    94: '^',
                    95: '_',
                    96: '`',
                    97: 'ި',
                    98: 'ޅ',
                    99: 'ސ',
                    100: 'ް',
                    101: 'ާ',
                    102: 'ަ',
                    103: 'ެ',
                    104: 'ވ',
                    105: 'މ',
                    106: 'އ',
                    107: 'ނ',
                    108: 'ކ',
                    109: 'ބ',
                    110: 'ދ',
                    111: 'ތ',
                    112: 'ހ',
                    113: 'ޫ',
                    114: 'ީ',
                    115: 'ު',
                    116: 'ޭ',
                    117: 'ރ',
                    118: 'ޔ',
                    119: 'ޮ',
                    120: 'ޑ',
                    121: 'ގ',
                    122: 'ޒ',
                    123: '÷',
                    124: '}',
                    125: '{',
                    126: '~'
                }
            };
            $(this).keypress(function (e) {
                if (e.ctrlKey) {
                    return true;
                } else if (e.which == 16) {
                    return true;
                } else {
                    if (keyboards[settings.keyboard][e.which]) {
                        var current, sTop = $(this).scrollTop();
                        if ($(this).get(0).selectionStart || $(this).get(0).selectionStart == 0) {
                            var selected = $(this).get(0).selectionStart + 1;
                            current = $(this).val().substring(0, $(this).get(0).selectionStart) + keyboards[settings.keyboard][e.which] + $(this).val().substring($(this).get(0).selectionEnd, $(this).val().length);
                            $(this).val(current);
                            $(this).get(0).setSelectionRange(selected, selected);
                            $(this).get(0).focus();
                        } else if (document.selection) {
                            var selected = document.selection.createRange();
                            selected.text = keyboards[settings.keyboard][e.which];
                            $(this).focus();
                        } else {
                            current = $(this).val();
                            current += keyboards[settings.keyboard][e.which];
                            $(this).val(current);
                        }
                        $(this).scrollTop(sTop);
                        return false;
                    } else {
                        return true;
                    }
                }
            });
        });
    };
})(jQuery);

$(selector).thaana();

的jsfiddle

这并不是说他们可以改变的语言,但如果你更改字体,并且字体产生的语言行为。

看看谷歌网络字体



Answer 2:

你提到的网站使用JavaScript通过完全不同的东西来代替窗体控件的正常功能。 您需要模仿,对于效果。



文章来源: how can i change default language and font of html textarea and disable other languages and font?