javascript - Cannot get chrome.window instance with chrome.app.window.get -


i'm trying following code when click on button:

chrome.app.window.create('sample.html', {         id: 'test',         'bounds': {           'width': 200,           'height': 200         },         'resizable' : false,         'frame': { type: "none" }     })     console.debug(chrome.app.window.getall())     var windowcreated = chrome.app.window.get('test');     windowcreated.innerbounds.height = 50;     windowcreated.innerbounds.width = 200; 

but here's console says:

uncaught typeerror: cannot read property 'innerbounds' of null

and debug of getall() returns original window created in background.js. don't i'm doing wrong...

chrome.app.window.create() asynchronous.

by time execution reaches chrome.app.window.get('test'), window not exist yet.

you need move logic in callback of chrome.app.window.create:

chrome.app.window.create('sample.html', {     id: 'test',     'bounds': {       'width': 200,       'height': 200     },     'resizable' : false,     'frame': { type: "none" } }, function(createdwindow) {   // stuff here, , no need get()   createdwindow.innerbounds.height = 50;   createdwindow.innerbounds.width = 200; }); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -