Javascript open.window returns null in called function
I have developed a function that, when called, should open a window, but return null
. If I open the window in a native JavaScript function, it works. I suppose its original function passes control to another function, but for some reason it doesn't work.
Here is my original function, this basically calls a new JavaScript file and loads the HTML file, and when "ready" it needs to display window.open with the HTML file now in string form.
order.prototype.printMe = function() {
order_resume.loadthis("myTestPage.html", "showData");
// OPENING WINDOW HERE WORKS; but the the html file that is loaded
// in above line hasn't finsihed loading - so i need to show it form
// the function below once in "ready" state
/* child1 = window.open ("about:blank","_blank");
child1.document.write( myDocument );
child1.document.close();
*/
}
And here is my function called from the original function:
function showResume() {
this.req = false;
reservaResumen.prototype.showData = function() {
if (this.req.readyState == 4) {
child1 = window.open("about:blank", "_blank"); /// THIS RETURNS NULL
child1.document.write("test");
child1.document.close();
}
}
reservaResumen.prototype.loadthis = function(url, myMethod) {
if (window.XMLHttpRequest && !(window.ActiveXObject)) {
try {
this.req = new XMLHttpRequest();
}
catch (e) {
this.req = false;
}
}
else if (window.ActiveXObject) {
try {
this.req = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
this.req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
this.req = false;
}
}
}
if (this.req) {
var loader = this;
this.req.onreadystatechange = function() {
eval("loader." + myMethod + ".call(loader)")
}
this.req.open("GET", url, true);
this.req.send("");
}
}
a source to share
See this discussion thread which attributes this issue to IE8 32-bit browser running on 64-bit Windows 7.
I just stumbled upon this a few days ago. My development machine started to behave differently, popups no longer work on many sites, including the one I'm developing, and no fixes are visible. I have to run IE as administrator then it works. Disabling Protected Mode does not allow this. This 64 bit browser does not have this problem.
Why, in my case, it only started a few weeks ago, I cannot say. There was a 9/16 security update that I suspect caused a change in behavior. It is very strange.
a source to share