Can not set property 'innerHTML' of null "ERROR" [closed]

-1
Hello, I'm trying to open an external site through a page that I created at the click of a button, but I can not reference the document I created, follow the code below, tried several times and could not, any help is valid, thank you .

<!DOCTYPE html>
<head>
	<title>Principal</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	
	<script src="\fswcorp\ceic\ssoa\gaacc\System\JQuery\jquery-3.2.1.min.js"></script>
	<script src="\fswcorp\ceic\ssoa\gaacc\System\jQueryMask\dist\jquery.mask.min.js"></script>
	<script src="\fswcorp\ceic\ssoa\gaacc\System\jQueryUI\jquery-ui.js"></script>
	<script>

	$(document).ready(function(){
		$("#dateBegin").mask('00/00/0000');
		$("#dateEnd").mask('00/00/0000');
	
		$("#buttonDownloadBRScan").click(function(){
			$windowopen = window.open();
			$windowopen.location.href = "https://www.fdibr.com.br/autenticacao/autenticacao/login";
			$test = $windowopen.document.getElementById("usuario").innerHTML = "7478704";
		})
	});
			
	</script>
</head>

<body>
	<div class="dataInput">
		<label id="labelDateBegin">Data Inicial</label>
		<input id="dateBegin" type="date"/>
		<label id="labelDateEnd">Data Final</label>
		<input id="dateEnd" type="date"/>
	</div>
	<br><br>
	<button id="buttonDownload">Download</button>
	<button id="buttonDownloadBRScan">Download BRScan</button>
</body>
    
asked by anonymous 12.04.2018 / 23:29

1 answer

1

You need to include a onload to know when the page opened with window.open has been loaded and thus change its element. But you also need to pass some parameter to window.open . You can put null .

  

For a change, it does not work in IE.

Change the part of your code to the below:

$(document).ready(function(){
   $("#dateBegin").mask('00/00/0000');
   $("#dateEnd").mask('00/00/0000');
   $("#buttonDownloadBRScan").click(function(){
      $windowopen = window.open(null);
      $windowopen.location.href = "https://www.fdibr.com.br/autenticacao/autenticacao/login";

      $($windowopen).on("load", function(){
         $($windowopen.document)
         .find("#usuario")
         .html("7478704");
      });
   });
});

Functional sample

    
13.04.2018 / 06:33