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

Alvistec spanish
Plan Alvistec in Youtube
Privacy policy

This web site uses third's cookies and the Google's cookies to offer services, personalize ads and analyze traffic (Google analytics).
The information on the use of the this web site is shared with Google and another ads provider platforms. When you using this web site, you accept cookies use.
See more about the Cookies

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