title: iFrame Javascript Across Subdomain
body: <p>I know this is a duplicate question however my requirements are slightly different,</p>
  
  <p>In a previous question this was tackled by setting:</p>
  
  <pre><code>document.domain = "yourdomain.com";
  </code></pre>
  
  <p>on both pages.</p>
  
  <p>However... I have a www.example.com domain and I have a mail.example.com </p>
  
  <p>the mail.example.com is a subdomain I have no access to, it is automatically generated by my shared hosting and its where i access my emails. However I want an iframe with mail.example.com as the source on one of my pages.</p>
  
  <p>e.g.</p>
  
  <pre><code>// www.example.com/mail.php
  &lt;html&gt;
      &lt;head&gt;...&lt;/head&gt;
      &lt;body&gt;
         ...
         &lt;? include("header.php"); ?&gt;
         ...
         &lt;iframe src="mail.example.com"&gt;&lt;/iframe&gt;
         ...
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This works as expected but certain styles are applied to the iframe, so i want to use javascript to remove all the styles, then add my own.</p>
  
  <p>But because i dont have access to mail.example.com, i cant set <code>document.domain = "example.com";</code> in the sub domain.</p>
  
  <p>Is there another way round this?</p>
  
  <p><b> EDIT </b></p>
  
  <p>I didn't make it very clear what I had already tried.</p>
  
  <p>This is my exact iframe code in my mail.php page on the www.example.com domain:</p>
  
  <pre><code>&lt;iframe id="mail" src="http://mail.a3mediauk.co.uk/mail2/source/index.php" height="800" width="960"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>This is the javascript code thats at the very top of the head element in the mail.php page:</p>
  
  <pre><code>document.domain = "http://mail.a3mediauk.co.uk";
  </code></pre>
  
  <p>And this is the jquery code im trying to use to remove the style:</p>
  
  <pre><code>$(function(){
      $("iframe#mail").load(function(){
          $("iframe#mail body").removeAttr("bgcolor");
      });
  });
  </code></pre>
  
  <p>if its any help, the document.domain throws this error in the chrome console:</p>
  
  <pre><code>Uncaught Error: SECURITY_ERR: DOM Exception 18
  </code></pre>