javascript - "'window.webkitStorageInfo' is deprecated" warning while iterating window object

Please consider the following code in htmljavascript:<html><head><script>var myObj

Please consider the following code in html/javascript:

<html>
<head>
<script>
    var myObject = {};
    var mySecondReference = myObject;

    for (s in window)
      if (window[s]===myObject)
        alert("reference found: " + s);
</script>
</head>
</html>

It iterates though the window object in order to search any references to a given object. It works fine everywhere, however in Chrome/ium gives me the following warnings:

'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
test.html:8 'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.

Is it something I should be scared of (especially with future versions of chrome browser)?

How can I get rid of those messages?

Please consider the following code in html/javascript:

<html>
<head>
<script>
    var myObject = {};
    var mySecondReference = myObject;

    for (s in window)
      if (window[s]===myObject)
        alert("reference found: " + s);
</script>
</head>
</html>

It iterates though the window object in order to search any references to a given object. It works fine everywhere, however in Chrome/ium gives me the following warnings:

'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
test.html:8 'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.

Is it something I should be scared of (especially with future versions of chrome browser)?

How can I get rid of those messages?

Share Improve this question edited Oct 11, 2017 at 7:57 Rodrigo de Farias 6572 gold badges8 silver badges20 bronze badges asked Mar 17, 2016 at 12:16 lviggianilviggiani 6,11612 gold badges61 silver badges93 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

It's not something you have to worry about, If you don't want to see them, just filter it

var myObject = {};
var mySecondReference = myObject;

for (s in window)
  if (!/webkitStorageInfo|webkitIndexedDB/.test(s) && window[s]===myObject)
    alert("reference found: " + s);

The error message tells you what you should do

'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.

test.html:8 'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.

So, instead of using window.webkitStorageInfo, use window.webkitTemporaryStorage or navigator.webkitPersistentStorage

You can check if these exist with something like this:

var storageInfo = null;

if(navigator.webkitTemporaryStorage) {
  storageInfo = navigator.webkitTemporaryStorage;
} else if(navigator.webkitPersistentStorage) {
  storageInfo = navigator.webkitPersistentStorage;
} else if (window.webkitStorageInfo) {
  storageInfo = window.webkitStorageInfo;
}

Same thing with the indexedDB deprecation message

var yourDB = null;

if(indexedDB) {
  yourDB = indexedDB;
} else if(webkitIndexedDB) {
  yourDB = webkitIndexedDB;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745254456a4618870.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信