javascript脚本里面的俄语字母转换成钻石

时间:2014-03-10 10:00:31

标签: javascript

我在页面上创建了这样的项目

    var list_item = "";
    if (eventstatus == 'CANCELED') {
         list_item = '<li class="media list-group-item list-group-item-info"  id="tooltip" data-toggle="tooltip" data-placement="right" title="Event canceled! Impossible to enroll!">';
         tooltipflag = true;
    }
    else list_item = '<li class="media list-group-item list-group-item-info">';
    list_item += '<a class="pull-left" href="#">';
    list_item += '<img class="media-object img-thumbnail" src="holder.js/200x120" alt="NO IMAGE">';
    list_item += "</a>";
    list_item += '<div class="media-body">';
    list_item += '<h4 class="media-heading">';
    if (eventstatus == 'CANCELED') list_item += name + ' <span class="label label-danger">' + eventstatus + ' <span class="glyphicon glyphicon-warning-sign"></span></span>';
    else if (eventstatus == 'DRAFT') list_item += name + ' <span class="label label-warning">' + 'SOON' + ' <span class="glyphicon glyphicon-pencil"></span></span>';
    else list_item += name + ' <span class="label label-primary">' + 'NEW' + ' <span class="glyphicon glyphicon-flag"></span></span>';
    list_item += '</h4>';
    list_item += '<p>' + description + '</p>';
    list_item += '<br>';
    list_item += '<div class="form-group pull-right">';
    list_item += '<button type="submit" class="btn btn-info btn-sm" data-toggle="modal" id="info_button' + i + '" data-target="#info' + i + '" >';
    list_item += '<span class="glyphicon glyphicon-info-sign"></span> Просмотреть информацию';
    list_item += '</button>';
    if (eventstatus == 'CANCELED') list_item += '<button type="submit" class="btn btn-success btn-sm disabled" data-toggle="modal" id="enroll" data-target="#enroll">';
    else list_item += '<button type="submit" class="btn btn-success btn-sm" data-toggle="modal" data-target="#enroll">';
    list_item += '<span class="glyphicon glyphicon-plus"></span> Записаться';
    list_item += '</button>';
    list_item += '</div></div></li>';
    return list_item;

但是Просмотреть информацию&amp; Записаться看起来像enter image description here

但如果我在html代码中编写它 - 而不是在javascript函数中 - 它看起来是正确的。

有什么问题?

1 个答案:

答案 0 :(得分:3)

假设您的文件以UTF-8正确编码并作为UTF-8(如有必要,请检查您的http服务器的设置),您可以在导入中以UTF-8声明脚本,如下所示:

<script charset="UTF-8" src="yourFile.js"></script>