How to set the scr in an iframe with javascript

Categories:  Web
Labels:  html, javascript

How to dynamically set the scr in an iframe javascript, with the following code you can make changes to the scr in an iframe using javascript, very usefull in html web desing.


<input type="button" name="calendarSelection" title="change" value="Change site" onClick="newSite()" />
<iframe id="myIframe" src="" onLoad="iframeDidLoad();"></iframe>


function iframeDidLoad() {

function newSite() {
 var sites = ['',
 document.getElementById('myIframe').src = sites[Math.floor(Math.random() * sites.length)];

Here’s the jQuery way to do it:

$('#calendar').attr('src', loc);


Related Posts:

Social Profiles

This web accept cryptocoin donations
BTC address, LTC, ETH, DASH, Uphold:
Why donations?