Rexluvplay Rexluvplay - 11 months ago 125
jQuery Question

jquery doesn't work on chrome

var h = 600;
var w = 1024;
var x = (screen.width - w) / 2;
var y = (screen.height - h) / 2;
var commonWindow = window.open(url, "", "screenX="+x+",screenY="+y+",left="+x+",top="+y+",width="+w+",height="+h);
var bankCdOpener = $("input[name=bankCd]", commonWindow.opener.document).val();
var branchCdOpener = $("input[name=branchCd]", commonWindow.opener.document).val();
$(commonWindow.document).ready(function () {
$("input[name=bankCd]", commonWindow.document).val(bankCdOpener);
$("input[name=branchCd]", commonWindow.document).val(branchCdOpener);
});


In the new open window, I can get the values of bankCd and branchCd from opener window when I run it on IE.

But it doesn't work on Chrome.
Here is the code, please help me.

Answer Source

Use load event of opened window

commonWindow.onload = function() {
  $("input[name=bankCd]", commonWindow.document).val(bankCdOpener);
  $("input[name=branchCd]", commonWindow.document).val(branchCdOpener);
}

plnkr http://plnkr.co/edit/xcMP7zQ5g6gEfJJu0On7?p=preview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download