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

php - Using str_replace to translate a MySQL Table in html -

SQL Server - MyCTE query based on 24 hour period (next day) -

asp.net mvc - Cannot display error message on Editor or EditorFor -