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();
}
精彩评论