if(!localStorage['option'] || localStorage['option'] == '2'){
chrome.tabs.create({url:'http://google.com'});
window.close;
self.close
}
When a user sets the option in the option page to 2, and presses the button, by default as set in the manifest.json file, a popup opens. Now the piece of code above is from the popup page itself. I want to close the popup when the option is set to 2. I tried (as you see) window.close and self.close (as stated in previous Stackoverflow topics), but those aren't working. How do i solve this puzzle?
I think you are missing the parentheses on the call of the window.close() function, as I read in this link http://groups.google.com/group/chromium-extensions/browse_thread/thread/637872124b91bf40?hide_quotes=no at the 4th comment.
It should work, if you add the parentheses, your code would be something like this:
if(!localStorage['option'] || localStorage['option'] == '2'){
chrome.tabs.create({url:'http://google.com'});
window.close();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.