I have the following in an html file (gallery.html) which creates a basic image gallery.
<div id="gallery">
<!-- images are loaded into the container via the javascript function -->
</div>
<script>
function loadImages(images) {
alert("Function Called");
for (var i = 0; i < images.length; i++) {
$('#gallery').append("<img class='slides' src='"+images[i]+"'/>");
}
}
</script>
I then want to be able to put it in an iFrame and call the function to load the Images.
For example I have tried this without success
<iframe src="gallery.html" width='400px' height="200px" onload='loadImages(['pic1.png','pic2.png'])'></iframe>
and
<iframe src="gallery.html" width='400px' height="200px" onload='this.contentDocument.loadImages(['pic1.png','pic2.png'])'></iframe>
Is there a way that I can call the function in this way (a one liner) via the iFrame element in HTML? This would mean then that I could just put this one line of code in where ever I wanted the gallery (with different images) on a website.
Thanks for looking!