Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating an iFrame within a table? 1

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
I have a table, and in one of the cells of each row I want an iFrame. This table is generated via asp code on the server, and the iframe's contents will be another table--like a sub-table I guess.

So then on certain events via javascript I'll reset the src of the iframe, changing the contents--the src will begin it's life blank, because I want to pre-generate the iframe's table contents.

So the problem is, on the original generation, I don't have an actual 'file' to set in the src tag--but I do have the actual html table code. I've tried just generating the html between the <iframe> and </iframe> tags, but that doesn't seem to work.

Is there a correct way to 'pre-generate' an iFrame's contents, or must i always use the src tag? BTW, on a lark I tried to put the html table in the Src tag and that didn't work either,
Thanks,
--Jim
 
Olaf,
That was an excellent idea! I got that working...though the getElementsByClass seems to be not supported in ie7 or is a user-defined function.

In lieu of that I just go through getElementsByTagName for the <tr> tags, and check for the specific prefix I generate for each parent row, and the <td> in question for each row is named in a strict convention so I can get that easily.

Thanks very much, this is a much more elegant way of doing it,
--Jim
 
Hi Jim,

glad you got it working. Yes, you're right that getElementsByClass is not a native javascript function. This would be an implementation of that, which would also enable you to only search within the table node (not the whole doc) and only certain tags, eg td.

Code:
function getElementsByClass( searchClass, domNode, tagName) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) {
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	}
	return el;
}

While the whole thing is a step in the right way instead of iframes you still create a lot of requests instead of one. you could fill the table witht the whole data immediately by calling that asp even without javascript on the server side to fill the table cells, then update individual cells by a modified javascript routine. But take one step after the other. A better intermediate step to gain performance would be starting css and getting rid of the table html.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top