title: Jquery replace with regex: replacing an attribute in SRC with another attribute
body: <p>I'm using Google Static Maps, which loads an image map:</p>
  
  <pre><code>&lt;img src="http://maps.google.com/maps/api/....&amp;someparameter&amp;someparameter&amp;scale=1"&gt;
  </code></pre>
  
  <p>Notice the <code>"scale=1"</code> parameter at the end. I need to replace it with <code>"scale=2"</code> only on high density displays with WebKit to load a high resolution version from Google.</p>
  
  <p>I'm using this find/replace script on DOM load with a condition, and it doesn't work. The window.devicePixelRatio works in WebKit (tested); but something is probably wrong with the function inside the if condition.</p>
  
  <pre><code>$(function()
      {
          if (window.devicePixelRatio &gt;= 1.5)
          {
              $('img[src*="scale=1"]').each(function() {
                  var newSrc = $(this).attr('src');
                  newStr = newSrc.replace('/scale=1/','scale=2');
                  $(this).attr('src', newSrc);
              });
          }
          else
          {
          }   
      });    
  </code></pre>
  
  <p>Thanks for suggestions!</p>