title: Replace domain in href using javascript in SharePoint
body: <p>I am currently developing a jquery function which I intend to use to replace url gates -> <a href="http://mydomain:20000" rel="nofollow">http://mydomain:20000</a></p>
  
  <p>As you know SharePoint use a usercontrol to embed the globalnavigation, and when rendered as HTML you find "/Subsite/Folder/Page.aspx" in the anchors tags' href.</p>
  
  <p>My problem here is that my colleague has managed to develop a cross-site navigation for a costumer, and that costumer also has a MySite which uses this cross-site navigation and MySites usually resides on another gate entry, in my case gate 20000.</p>
  
  <p>So in order for the users to navigate around without getting 403 errors just because the cross-site navigation doesn't remove the :20000 entry I want to use a jquery script to remove that entry. Only problem - Don't know how.</p>
  
  <p>A scrapped version:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () { 
          var urlContain = new RegExp(':20000');
          $('#s4-topheader2 a').each(function () { 
              var href = this.getAttribute('href').replace(urlContain, '');
              $(this).attr('href', href);
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>It works as intended, but unfortunately, it doesn't remove the :20000 from the domain, as I mentioned earlier, the anchors only seems to contain "/Subsite/Folder/Page.aspx" when rendered. Though when I hover over them, I can see in the bottom left corner of my browser that it contains the domain name, but not when I <em>View source</em>.</p>
  
  <p>Ideas and thoughts to solve this are highly appreciated.</p>