html5桌面通知

<!doctype html>
<html>
	<head>
	</head>
	<body>
        <script>
		 if(window.webkitNotifications){
		   window.webkitNotifications.requestPermission();
		   if(window.webkitNotifications.checkPermission()==0){
		     var obj=window.webkitNotifications.createNotification("1.jpg","標題","內容");//創建桌面通知
             obj.tag="houdun"
			 obj.show();
			 obj.οnshοw=function  () {
		
			 }
			 obj.οnclick=function  () {
			   alert("我點擊了");
			 }
		   }
		 }
		</script>
	</body>
</html>

<!doctype html>
<html>
	<head>
	</head>
	<body>
        <script>

		window.οnlοad=function  () {
		 var mp3=document.getElementById("mp3");
		 var time=new Date();
		 var str="0"+(time.getMonth()+1)+"-0"+time.getDate();07-08
		 if(localStorage.getItem("time")){
		   var newstr=localStorage.getItem("time").substr(5)
		   if(newstr===str){
		       if(window.webkitNotifications){
			     window.webkitNotifications.requestPermission();
					 if(window.webkitNotifications.checkPermission()==0){
					  var obj=window.webkitNotifications.createNotification("1.jpg","註冊時間","恭喜你註冊一年了");
					    obj.show();
					  obj.οnshοw=function  () {
					     mp3.play();
					  }
					  obj.onclose=function  () {
					   mp3.pause() 
					  }
					 }
			   }
		   
		   }
		 }
		 var date=document.getElementById("date");
		 date.οnchange=function  () {
		   localStorage.setItem("time",date.value);
		 }
		}
		</script>

		<input type="date" name="date" id="date">
		<audio src="1.mp3" id="mp3">
		</audio>
	</body>
</html>

發佈了96 篇原創文章 · 獲贊 4 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章