在许多网站中,他们会在右下角或左下角弹出的警报通知中显示新访客登陆页面
下面的代码工作得很好,除了我没有成功更改消息文本:
将标准 Bootstrap 警报变成令人敬畏的通知
我想通过自定义消息更改这行文本,但我找不到如何用变量示例替换此硬编码消息:
varwelcome='欢迎来自澳大利亚的访客';
<script type="text/javascript" language="JavaScript">
'use strict';
$(window).on('load', function() {
function notify(message, type) {
$.notify({
message: message
}, {
type: type,
allow_dismiss: false,
label: 'Cancel',
className: 'btn-xs btn-inverse',
placement: {
from: 'bottom',
align: 'right'
},
delay: 2500,
animate: {
enter: 'animated bounceInUp',
exit: 'animated bounceOutUp'
},
offset: {
x: 30,
y: 30
}
});
};
notify('Welcome to Notification page', 'inverse');
});
$(document).ready(function() {
function notify(from, align, icon, type, animIn, animOut) {
$.notify({
icon: icon,
title: ' Bootstrap notify ',
message: 'Turning standard Bootstrap alerts into awesome notifications',
url: ''
}, {
element: 'body',
type: type,
allow_dismiss: true,
placement: {
from: from,
align: align
},
offset: {
x: 30,
y: 30
},
spacing: 10,
z_index: 999999,
delay: 2500,
timer: 1000,
url_target: '_blank',
mouse_over: false,
animate: {
enter: animIn,
exit: animOut
},
icon_type: 'class',
template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" role="alert">' +
'<button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button>' +
'<span data-notify="icon"></span> ' +
'<span data-notify="title">{1}</span> ' +
'<span data-notify="message">{2}</span>' +
'<div class="progress" data-notify="progressbar">' +
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
'</div>' +
'<a href="{3}" target="{4}" data-notify="url"></a>' +
'</div>'
});
};
</script>
我尝试用变量welcome替换硬编码短语
只需更改您的行
message: 'Turning standard Bootstrap alerts into awesome notifications',
到
message: 'Welcome visitor from Australia',