I'm trying to load content into an iframe by clicking on a link. Specifically, I have many tables all loaded into one HTML document, and I need to load each individual table based on the link that is clicked (ie. clicking the "money" link will load the "money table"). I've already loaded the file into the iframe document with "src". My approach right now is loading an iframe with the content and then dynamically writing inside the iframe itself. The code I'm writing in the iframe is the innerHTML of external document with all the tables (innerHTML of the specific table). However, I'm having a little trouble accessing the external document; this is what I have so far:
-
function displayTable(tableId)
-
{
-
var id=document.getElementById(tableId);
-
//i found this somewhere on the internet - I'm not exactly sure if this is correct
-
var ifrm=(id.contentWindow)?id.contentWindow:(id.contentDocument.document)?id.contentDocument.document:id.contentDocument;
-
if (id.style.visibility="hidden")
-
{
-
id.style.visibility="visible";
-
id.style.height="600px";
-
ifrm.document.open();
-
ifrm.innerHTML = ifrm.document.anchors(ifrm.document.getElementById(tableId)).innerHTML;
-
ifrm.close();
-
}
-
Any help appreciated! I just learned Javascript yesterday, so any points in the right direction would be great.