0

I get a weird error when I try to ask for permissions for displaying desktop notifications on Safari I get a typeError. I got a button which triggers `window.webkitNotifications.requestPermission()' onclick.

HTML Code:

<button id='btn'>Request Permissions</button>

Javascript:

var btn = document.getElementById( 'btn' );
btn.onclick = function () {
    window.webkitNotifications.requestPermission();
}

This snippet works fine on Chrome, but on Safari throws a typeError.

The website runs on localhost.

Paris
  • 6,323
  • 7
  • 31
  • 49
  • 1
    *TypeError* is a value type issue. Shouldn't Safari `requestPermission` expect a callback? – Jay Oct 23 '12 at 00:42
  • Yes actually you are right. I assumed that it would be more handy if I didn't give a callback at all instead of giving an empty function :P. Unfortunately Safari doesn't accept that. – Paris Dec 27 '12 at 00:33
  • This answer works in safari and chrome http://stackoverflow.com/a/13328513/218418 – Rodrigo Polo Nov 24 '13 at 00:03

0 Answers0