Battery API is not working on chrome pop up window

2019-09-06 06:22发布

问题:

is there a way to get the Battery object in chrome pop up windows

I am using this code to create pop up

chrome.windows.create({'url': 'mypop.html', 'type': 'popup'}, function(window) {
  });

but having problem to return the battery object using this code

var battery = navigator.webkitBattery;

when I am calling the javascript file on the mypop.html page.

Is it the chrome security issue that disallow battery object on pop up page?

回答1:

Looks like its been removed from Chrome as navigator.webkitBattery is undefined



回答2:

Chrome developer advocate has replied over here on SO. Checkout this thread.

navigator.webkitBattery not working in Google chrome