Surprised to find today, CHROME22 has not supported the Window.webkitNotifications.createHTMLNotification method:
However, you can continue to use it in Chrome extension, such as the page performance detection feature in Fehelper:
What is Google doing here? Gradually to achieve their own standardization?
WEB notification does not createhtmlnotification such a method, or even createnotification.
Instead, it is a simple constructor:
var notification = new Notification( "我的消息" ,{ body : ‘内容‘ , iconUrl : ‘图标‘ , tag : {}, // 可以加一个tag }); notification.show(); |
It seems that only Chrome has this API right now:
After the rewrite:
<!DOCTYPE HTML><HTML><Head><title>Google Desktop Notifications</title><Metaname= "Generator"content= "EditPlus" /><Metaname= "Author"content="" /><Metaname= "keywords"content="" /><Metaname= "description"content="" /><Metahttp-equiv= ' Content-type 'content= ' text/html;CharSet=utf-8 '/></Head><Body><ButtonID= ' btn '>Show Desktop Notifications</Button> <Scripttype= ' Text/javascript '>Document.queryselector ("#btn"). AddEventListener ('Click', notify,false);functionNotify () {if(window.webkitnotifications) {Console.log (123); if(Window.webkitNotifications.checkPermission ()== 0) { varnotification_test=Window.webkitNotifications.createNotification ("http://images.cnblogs.com/cnblogs_com/flyingzl/268702/r_1.jpg", 'title', 'content'+NewDate (). GetTime ()); Notification_test.display= function() {} Notification_test.onerror= function() {} Notification_test.onclose= function() {} Notification_test.onclick= function() { This. Cancel (); Notification_test.replaceid= 'Meteoric'; Notification_test.show (); varTemppopup=window.webkitNotifications.createHTMLNotification (["http://www.baidu.com/", "http://www.soso.com"][math.random ()>= 0.5 ? 0 : 1]); Temppopup.replaceid= "Meteoric_cry"; Temppopup.show (); } Else{window.webkitNotifications.requestPermission (notify); } } Else{Console.log (456); varNotification= NewNotification ("my message.", {body:'content', IconUrl:'Https://dn-st.b0.upaiyun.com/v4.9.x/images/49751d86.touch-icon-ipad.png', tag: {}//You can add a tag }); Notification.show (); } }</Script></Body></HTML>
Note: The red section above is the new Chrome pop-up popup notification feature
Chrome does not support the Window.webkitNotifications.createNotification message notification API.