What could cause window.open to return "undefined"?

I have the following script in my Xul application:

MyClass = function() {
 this.go = function() {
  try {
   var scanWindow = window.open('chrome://test/content/scanWindow.xul','Scan','chrome, width=850, height=150, centerscreen');
   dump("scanWindow = " + scanWindow); // console output in Xul
  } catch(err) {
   dump("ERROR: " + err); // console output in Xul
  }
    }
}

when i call this method it prints

scanWindow = undefined

Any hint on what might be causing this?

+3
source share
3 answers

Found: what could cause this behavior is to overwrite the window.open method and return nothing. How it was done in another part of this code.

-1
source

I do not think you can open spaces in the third argument.

Wrong:

var scanWindow = window.open('chrome://test/content/scanWindow.xul','Scan','**chrome, width=850, height=150, centerscreen**');

Correctly:

var scanWindow = window.open('chrome://test/content/scanWindow.xul','Scan','**chrome,width=850,height=150,centerscreen**');
+1
source
var goWindow = window.open('chrome://test/content/go.xul','Go','chrome, width=850, height=150, centerscreen');
dump("scanWindow = " + scanWindow); // console output in Xul    

your dump call should be

dump("scanWindow = " + goWindow); // console output in Xul    
0
source

Source: https://habr.com/ru/post/1784787/


All Articles