通知APIを試すこともできます。ここでは例です:
function message(msg){
if (window.webkitNotifications) {
if (window.webkitNotifications.checkPermission() == 0) {
notification = window.webkitNotifications.createNotification(
'picture.png', 'Title', msg);
notification.onshow = function() { // when message shows up
setTimeout(function() {
notification.close();
}, 1000); // close message after one second...
};
notification.show();
} else {
window.webkitNotifications.requestPermission(); // ask for permissions
}
}
else {
alert(msg);// fallback for people who does not have notification API; show alert box instead
}
}
単に書き、これを使用するには:
message("hello");
の代わりに:
alert("hello");
注:それが唯一の現在サポートされているということを覚えておいてくださいChrome、Safari、Firefox、モバイルウェブブラウザ(2014年1月)
の
サポート検索ブラウザhere.
トラヴィスさん、ありがとうございました。カスタムアラートではなくアラートが必要です – maherelghali
これまでのところ、ソリューションには近すぎます。試してみます。 – maherelghali
こんにちは、parentNodeでnullを取得しています...行のel.parentNode.removeChild(el); ..それを修正する方法。 – goku