初始化新变量时,JavaScript代码中断

时间:2019-06-14 03:00:26

标签: javascript google-chrome

我有这个功能:

function decryptSearch(searchURL) {
  var spaceHash = ' ';
  //var searchString = searchURL.substring(searchURL.search('q='));
  //searchString = searchString.substring(0, searchString.at('&'));
  if (searchURL.startsWith('https://www.google.com/search'))
    spaceHash = '+';
  else if (searchURL.startsWith('https://www.bing.com/search'))
    spaceHash = '%20';
  chrome.storage.sync.set({search_query: searchURL});
}

当我取消注释这两行时,chrome存储不会更新。我完全不知道为什么要这么做,甚至都没有修改变量。

1 个答案:

答案 0 :(得分:-1)

searchString.at不是JavaScript中的函数。我认为您想要searchString.indexOf