如何更改html textarea的默认语言和字体并禁用其他语言和字体? [英] how can i change default language and font of html textarea and disable other languages and font?

查看:128
本文介绍了如何更改html textarea的默认语言和字体并禁用其他语言和字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个注释框(textarea).我想首先更改文本区域的默认语言和默认字体,而客户端则不能更改语言或字体. http://www.haveeru.com.mv/dhivehi/business/126135 转到此链接,然后单击下面的发表评论"按钮.将显示一个文本区域.这正是我想要的方式.相同的languge(divehi)相同的字体.我尝试了很多方法.但是它在开始时使用了英语.谢谢. /p>

I have a comment box(textarea).I want to change default language of the textarea and default font at first without the client be able to change the language or font. http://www.haveeru.com.mv/dhivehi/business/126135 go to this link and click Post comment button below.a textarea will appear.it is exactly how i wish to do.same languge(divehi) same font.i tried in many ways.but it use english at start.thank you.

推荐答案

他们使用自己的字体,每当您想查看某人使用的字体/大小/颜色时,请查看view-source,在这种情况下为css

They are using their own font, every time you want to see what font/size/color someone is using look at view-source, in this case the 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扩展

or Javascript extend

(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

不是他们可以更改语言,而是如果您更改字体,字体就会产生语言行为.

It's not that they can change the language, but if you change the font, and the font produces the language behavior.

看看 Google Web字体

这篇关于如何更改html textarea的默认语言和字体并禁用其他语言和字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆