JSFiddle - React, Tailwind, and code Playground

by amirshim

JavaScript

$(function() {
    var use_unique_name = true;

    var imgsrc = 'http://www.jaavuu.com/content/1/slides/jaavuu-one-event-one-gallery.jpg';
    if (use_unique_name) {
        var ts = +(new Date());
        // try replacing _= if it is there
        var ret = imgsrc.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
        // if nothing was replaced, add timestamp to the end
        imgsrc = imgsrc + ((ret == imgsrc) ? (imgsrc.match(/\?/) ? "&" : "?") + "_=" + ts : "");
    }
    
    var ifr = $('<iframe src="/echo/js"/>');
    $('body').append(ifr);
    ifr.load(function() {
        var cd = ifr[0].contentDocument;
        
        $(cd).find('body').append('<img id="imgloader" />');
        var im1 = $(cd).find('#imgloader');
        im1[0].onload = function() {
            $('body').append('<img src="'+imgsrc+'" />');
        };
        im1[0].src = imgsrc;
    });
    
});