chrome.tags.getでエラーが出るので、onRemovedで先にチェックする

http://code.google.com/chrome/extensions/tabs.html

chrome.tabs.get(tab.id ,function(tab){
             if( typeof(tab)===’undefined’){
// not found
             }else{
             }
});
Error during tabs.get: No tab with id: 2187. sendRequest:20
chromeHidden.handleResponse

undefinedの時は、タブが無いということで問題なく処理出来るのですが、(例外にもなりません。)
consoleにメッセージがでるので、先に使えないIDをチェックします。

grBk.tabsに適当なタブのオブジェクトが入っていてtab.idでタブのIDを保持しています。

chrome.tabs.onRemoved.addListener(function( tabId,  removeInfo) {  // check active tab
 for( i in grBk.tabs ){
   if( grBk.tabs[i].tab &&
       grBk.tabs[i].tab.id &&
       grBk.tabs[i].tab.id == tabId ){
     grBk.tabs[i].tab = null;
     console.log( ‘removed ‘+i+’ : ‘+tabId );
   }
 }
};

This entry was posted on 火曜日, 7月 24th, 2012 at 11:15 PM and is filed under Chrome Extention. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。