setInterval()을 사용하여 가능합니까? 아래의 예에서 매주 금요일 16:00에 Javascript 알림을 실행하는 방법
, 경고 내가 어쩌면 가장 좋은 방법이 아닙니다, 간격 함수 내에서 사파리 푸시 알림을 실행하기 위해 노력하고있어<script type="text/javascript">
setInterval(function() {
// alert("Message to alert every 5 seconds");
}, 5000);
</script>
... 5 초마다,하지만 그건 지금
function Notifier() {}
// Returns "true" if this browser supports notifications.
Notifier.prototype.HasSupport = function() {
if (window.webkitNotifications) {
return true;
} else {
return false;
}
}
// Request permission for this page to send notifications. If allowed,
// calls function "cb" with true.
Notifier.prototype.RequestPermission = function(cb) {
window.webkitNotifications.requestPermission(function() {
if (cb) { cb(window.webkitNotifications.checkPermission() == 0); }
});
}
// Popup a notification with icon, title, and body. Returns false if
// permission was not granted.
Notifier.prototype.Notify = function(icon, title, body) {
if (window.webkitNotifications.checkPermission() == 0) {
var popup = window.webkitNotifications.createNotification(
icon, title, body);
popup.show();
return true;
}
return false;
}
$(function() {
var notifier = new Notifier();
if (!notifier.HasSupport()) {
$("#error").show();
return;
}
$("#request-permission").click(function() {
$("#error").hide();
notifier.RequestPermission();
});
$(function() {
if (!notifier.Notify("#", "MESSAGE")) {
$("#error").text('Permission denied. Click "Request Permission" to give this domain access to send notifications to your desktop.');
$("#error").show();
} else {
$("#error").hide();
}
});
});
그것은 여기 수학 문제처럼 더 :))하는 시간을 밀리 초 단위로 각 금요일 16시 사이 – NinjaShawarma
무엇 5 초 루프 오후 4 @ 금요일에해야 할 것인가? – j08691
@ j08691 매주 금요일 16시에이 경고가 필요합니다. 이해가 되시나요? – NinjaShawarma