Помогите с уведомлениям. Пожалуйста.
Здравствуйте, помогите пожалуйста с Уведомлениями хочу сделать так что бы уведомления показывалось не при нажатие кнопки, а просто выскакивало и только один раз.
скачал скрипт вот здесь А вот код Html <button id="notification-trigger" class="progress-button"> <span class="content">Show Notification</span> <span class="progress"></span> </button> И JS
<script>
(function() {
var bttn = document.getElementById( 'notification-trigger' );
// make sure..
bttn.disabled = false;
bttn.addEventListener( 'click', function() {
// create the notification
var notification = new NotificationFx({
message : '<span class="icon icon-settings"></span><p>Your preferences have been saved successfully. See all your settings in your <a href="#">profile overview</a>.</p>',
layout : 'bar',
effect : 'exploader',
ttl : 9000000,
type : 'notice', // notice, warning or error
onClose : function() {
bttn.disabled = false;
}
});
// show the notification
notification.show();
// disable the button (for demo purposes only)
this.disabled = true;
} );
})();
</script>
|
notificationFx
dezytube,
так выкиньте всё что связано с кнопкой
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/demo.css">
<link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-style-bar.css">
<link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-default.css">
<style type="text/css">
body{
background-color: rgb(0, 128, 128);
}
</style>
</head>
<body>
<script src="http://tympanus.net/Development/NotificationStyles/js/modernizr.custom.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/classie.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/notificationFx.js"></script>
<script>
(function() {
// create the notification
var notification = new NotificationFx({
message : '<span class="icon icon-settings"></span><p>Your preferences have been saved successfully. See all your settings in your <a href="#">profile overview</a>.</p>',
layout : 'bar',
effect : 'exploader',
ttl : 9000000,
type : 'notice', // notice, warning or error
onClose : function() {
}
});
// show the notification
notification.show();
})();
</script>
</body>
</html>
|
рони,
Спасибо но это я сделал я говорю о том как мне сделать что бы показывало только один раз что бы не напрягать гостя. |
cookie - флаг повести
|
cookie через localStorage показать 1 раз
dezytube,
в строке 37 установите время(месяц, год) через которое сообщение снова появится при заходе на сайт ... сейчас строит запрет на 20 секунд.
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/demo.css">
<link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-style-bar.css">
<link rel="stylesheet" type="text/css" href="http://tympanus.net/Development/NotificationStyles/css/ns-default.css">
<style type="text/css">
body{
background-color: rgb(0, 128, 128);
}
</style>
</head>
<body>
<script src="http://tympanus.net/Development/NotificationStyles/js/modernizr.custom.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/classie.js"></script>
<script src="http://tympanus.net/Development/NotificationStyles/js/notificationFx.js"></script>
<script>
(function() {
function show() {
var notification = new NotificationFx({
message: '<span class="icon icon-settings"></span><p>Your preferences have been saved successfully. See all your settings in your <a href="#">profile overview</a>.</p>',
layout: "bar",
effect: "exploader",
ttl: 9E6,
type: "notice",
onClose: function() {}
});
notification.show()
}
var limit = 20 * 1E3; //24 * 3600 * 1000; 24 часа
var localStorageInitTime = localStorage.getItem("localStorageInitTime");
if (localStorageInitTime === null) {
localStorage.setItem("localStorageInitTime", +new Date);
show()
} else if (+new Date - localStorageInitTime > limit) {
localStorage.clear();
localStorage.setItem("localStorageInitTime", +new Date);
show()
}
})();
</script>
</body>
</html>
|
рони,
Очень тебе благодарен.. |
рони,
Ты хороший человек.. |
| Часовой пояс GMT +3, время: 22:21. |