开发者

chrome extension opens javascript popup window then alerts in that window fails

function openindex()
{
OpenWindow=window.open("", "newwin", "height=768, width=1024,toolbar=no,scrollbars=no,menubar=no, location=no");
OpenWindow.alert("hi");
}

openindex();

So开发者_开发百科 this fails, a window is created blank or loads a webpage, there is no alert. Of course this works in a html document, but as a extension it fails and I do not know why.


Not sure if this is the issue, but:

According to the original specs (Netscape) for window.open the feature string must NOT contain spaces.

PS if you set the url to "about:blank" first, then use (the following) does it work?

function openindex(){
  OpenWindow = window.open("about:blank", "newwin", "height=768,width=1024,toolbar=no,scrollbars=no,menubar=no,location=no");
  OpenWindow.document.write('<script>alert("Hi");</script>');
  OpenWindow.document.close();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜