开发者

What can cause a window.open to return "undefined"?

I have the following script in my Xul app:

MyCla开发者_JAVA百科ss = 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 can be causing that?


I don't think you can have spaces in the third argument to open.

Wrong:

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

Correct:

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


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

your call to dump should be

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


Found out: what can cause this behavior is to re-write the window.open method, and return nothing. As it was done in another part of this code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜