2015-06-01 92 views
1

我在asp.net中使用下面的javascript進行桌面通知。在按鈕上單擊此事件可以正常工作,但在執行代碼時會出錯。asp.net中的桌面通知

這個代碼在我的網頁添加...

<script type="text/javascript"> 
     function notifyMe() { 
      if (!("Notification" in window)) { alert("This browser does not support desktop notification"); } 
      else if (Notification.permission === "granted") { 
       var options = { 
        body: "This is the body of the notification", 
        icon: "stupidcodes.com.png", 
        dir: "ltr" 
       };     

       var notification = new Notification("Hi there", options); 

       notification.onclick = function() { 
        window.open("http://www.stupidcodes.com/"); 
       }; 
      } 
      else if (Notification.permission !== 'denied') { 
       Notification.requestPermission(function (permission) { 
        if (!('permission' in Notification)) { 
         Notification.permission = permission; 
        } 
        if (permission === 'granted') { 
         var options = { 
          body: 'This is the body of the notification', 
          icon: 'stupidcodes.com.png', 
          dir: 'ltr' 
         }; 
         var notification = new Notification('Hi there', options); 
         notification.onclick = function() { 
          window.open('http://www.stupidcodes.com/'); 
         }; 
        } 
       }); 
      } 
     } 

是否有添加通知這樣在asp.net

可以通過這個代碼的方法working here

+0

你有這個工作嗎? –

+0

沒有還沒有@SachinTrivedi –

回答

0

請檢查出my blog post。我已經創建了一個樣本,將在文檔加載時觸發通知。您可以根據您的要求利用代碼。

+0

讓看看會確認你能回覆我目前的問題@Sachin –

+0

請指出你得到的錯誤是什麼。 –

+0

http://stackoverflow.com/questions/33255591/get-filter-the-date-rand-in-sql-server/33255764#33255764檢查此 –