JSFiddle - React, Tailwind, and code Playground

by Paul Leech

HTML

<input type="button" value="Change site" onClick="newSite()" /><br>
<iframe id="myIframe" src="http://bing.com/" onLoad="iframeDidLoad();"></iframe>

CSS

#myIframe {
    width: 600px;
    height: 600px;
}

JavaScript

function iframeDidLoad() {
    console.log('Done');
}

function newSite() {
    var sites = ['http://lifehacker.com',
                 'http://bing.com/',
                 'http://lifehacker.com/']
    
    document.getElementById('myIframe').src = sites[Math.floor(Math.random() * sites.length)];
}