1

I'm building an automation script in JavaScript to pass variables into an input form into a child window. Every time I go to return the element ID from the child window, the JS console tells me it

cannot find the property 'onload' of an undefined or null reference.

My first thought was I wasn't calling the window properly. But I've checked, both URLs are from the same domain, so it wouldn't violate the same origin principle. I'm just completely stuck and hoping someone could help.

I can't give any more detail than what I have in the code because I am working on a proprietary system.

var WinName = "";

function getWindowName() {
  var d = new Date();
  d = d.toUTCString();
  d = d.split(' ');

  for (var i = 0; i < d.length; i++) {

    d[i]= d[i].replace(/\W/,'');
    d[i]= d[i].replace(":",'');

  }
  WinName = d.join('');
  return WinName;
}

var b = getWindowName();
var a = window.open([URL], b).focus();
a.onload = document.getElementById([ElementID]);'
Don't Panic
  • 41,125
  • 10
  • 61
  • 80

0 Answers0