Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Went away for a rest, then came back and discovered I had been testing my code by refreshing and refreshing the out-of-date copy on the server instead of the one I was editing at localhost.</p> <p>Sorry! I have been working too long.</p> <p>Here is a working version of the code:</p> <pre><code>function js_imgs() { if (document.documentElement.clientWidth &lt;= 600) { $("img").each(function(){ if ($(this).hasClass('big')) { var oldSrc = $(this).attr('src'); var newSrc = oldSrc.substring(0, oldSrc.lastIndexOf('/')) + oldSrc.substring(oldSrc.lastIndexOf('/'), oldSrc.lastIndexOf('.')); $(this).attr('src', newSrc + '-m.' + /[^.]+$/.exec(oldSrc)); $(this).removeClass('big').addClass('mobile'); } }); } else { $("img").each(function(){ if ($(this).hasClass('mobile')) { var oldSrc = $(this).attr('src'); var newSrc = oldSrc.substring(0, oldSrc.lastIndexOf('/')) + oldSrc.substring(oldSrc.lastIndexOf('/'), oldSrc.lastIndexOf('.')); $(this).attr('src', newSrc.replace(/([^.]*)-m/, "$1") + '.' + /[^.]+$/.exec(oldSrc)); $(this).removeClass('mobile').addClass('big'); } }); } }; js_imgs(); $(window).resize(function($){ js_imgs(); }); </code></pre> <p>This is written for on-the-fly switching on window resizes, which is almost certain to be entirely unnecessary. Perhaps when switching from portrait to landscape on high-resolution iPhones or tablets, the extra code might be worthwhile; I will have to do some testing.</p> <p>Improvements and comments on the worthiness of on-the-fly switching more than welcome.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload