1

i'd set scripts (background.js) as Background in manifest.json.

and write the code blow to background.js:

var source = new EventSource('http://localhost:8086/test/');
source.addEventListener('ping', function (e) {
    var notification = webkitNotifications.createNotification(
      'test.png',
      'testTitle',
      'testContent'
    );
    notification.show();
}, false);

these code could run correct as normal html page under http://localhost:8086/, but it doesn't run at all in the Chrome extension.

I've put http://localhost:8086/ into "permissions" of manifest.json.

Rob W
  • 341,306
  • 83
  • 791
  • 678
user1566268
  • 75
  • 11
  • the "localhost:8086" above should write "http://", but stackoverflow.com do not permit write "http://localhost:8086". – user1566268 Jul 27 '12 at 00:14
  • 1
    In the permissions section, you need a wilcard after `..:8086/`, `..:8086/*`. Looks like a duplicate of [Failing AJAX request in a Chrome extension, with correct manifest permissions?](http://stackoverflow.com/questions/9947014/failing-ajax-request-in-a-chrome-extension-with-correct-manifest-permissions). – Rob W Jul 27 '12 at 09:43

0 Answers0