How to change img src on document ready before browser downloads images?
<p>On my page I have some images on thisdomain.com/images.  on document.ready(), I change the src attribute of images to thatdomain.com/images.  Firebug's Net tab shows me that images are downloaded from both thisdomain.com and thatdomain.com.  How can I prevent the browser from downloading images from thisdomain.com?</p>

<pre><code>$(document).ready(function(){
    $("img").each(function() {
        var $img = $(this);
        var src = $img.attr("src");
        $img.attr("src", src.replace(/thisdomain.com.com\/images/i, "thatdomain.com\/images"));
    });
});
</code></pre>

<p>EDIT: ASP.NET server-side override of Render() using code "in front" i.e., &lt;script runat="server"&gt;  I just added this to the aspx page without recompiling code-behind.  It's a bit hack-ish but it works.</p>

<pre><code>&lt;script runat="server"&gt;        
    static Regex rgx = new Regex(@"thisdomain.com/images", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {   
        using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
        {   
            base.Render(htmlwriter);
            string html = htmlwriter.InnerWriter.ToString();

            string newHtml = rgx.Replace(html, "thatdomain.com/images");
            writer.Write(newHtml.Trim());
        }
    }
&lt;/script&gt;
</code></pre>
