0

I am trying to create a new window using the code below :


  var createData = {
            "url" : wikiUrl ,
            "type" :"popup" ,
            "top" : 5 ,
            "left" : 5 ,
            "width" :  Math.round((chrome.windows.getCurrent().width)/2),
            "height" : Math.round((chrome.windows.getCurrent().height)/2)

chrome.windows.create(createData,function(){}) ; 

But get

Error at parameter 'createData': Error at property 'width': Invalid type: expected integer, found number.

The values of width and height are being set as NaN (through debugging) .

But setting the height and width like below :


"width" :  ((chrome.windows.getCurrent().width)),
"height" : ((chrome.windows.getCurrent().height))

does create a new window with lesser dimensions than the current window .

why does this happen ?

I'm guessing there is some kind of limit to dimensions of the new windows created, But I don't find any documentations regarding it .

akashKP
  • 137
  • 9
  • 1
    chrome.windows.getCurrent() returns a Promise, not a window object, so your formula calculates as `NaN`, which is an invalid number and not an integer. Your second formula calculates to `undefined` which means the value is ignored. See [How do I return the response from an asynchronous call?](https://stackoverflow.com/q/14220321) – wOxxOm Jun 11 '23 at 16:11

0 Answers0