March 3, 2012
how to open a page and force an iframe load?
Question by Lucas Matos
I would like to know is it possible to, when clicking a link, open a main page and force to load another page in a frame inside the main page?
Any idea?
Answer by Starx
Include the following js
script on the main page
and you are done
function loadframe(){
var i = document.getElementById("iframeID");
i.src = "path/to/file";
};
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", loadIframe, false);
else if (window.attachEvent)
window.attachEvent("onload", loadIframe);
else window.onload = loadIframe;