Currently I am trying to load an Iframe within TabContent. Why is this external webpage not loading correctly when the tab is selected?
Fiddle: https://jsfiddle.net/hpjnkmz1/1/
HTML:
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'PageOne')">Page One</button>
<button class="tablinks" onclick="openCity(event, 'PageTwo')">Page Two</button>
<button class="tablinks" onclick="openCity(event, 'PageThree')">Page Three</button>
</div>
<div id="PageOne" class="tabcontent">
<h3>London</h3>
<p>London is the capital city of England.</p>
</div>
<div id="PageTwo" class="tabcontent">
<h3>Paris</h3>
<p>Paris is the capital of France.</p>
</div>
<div id="PageThree" class="tabcontent">
<div id="siteloader"></div>
</div>
</body>
</html>
JavaScript:
function loadContent(id, url) {
var node = document.getElementById(id);
node.innerHTML = url;
}
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
if (cityName == 'PageThree') {
alert("Load External Content");
$("#siteloader").html('<iFrame src="http://validator.w3.org/">');
}
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}