title: Dynamically set document.domain to iframe
body: <p>I have an iframe that injects in pages, called him &quot;helper&quot;. So due to same origin policy I need to set iframe domain the same is parent window domain. But I can't get access to parent window domain. How can it be solved?</p>
  <p>This code is currently working for 2nd level domains:</p>
  <pre><code>pathArray = window.location.host.split('.');
  var arrLength = pathArray.length;
  var domainName = pathArray.slice(arrLength - 2, arrLength).join('.');
  document.domain = domainName;
  </code></pre>
  <p>but I need to somehow get it from parent window rather than relying on 2nd level domain</p>