Wednesday, 30 July 2008

Hiding borders on IFrames with Related Regarding objects

I won't bore you with the details of how to add an iFrame that will display related regarding objects on the parent object's form, and why you might want to do that - there've already been plenty of blogs out there about that (Eg Huib Aarts' article on the subject). However, I've noticed that when I implemented my version of it, the pesky borders wouldn't go away, and the article linked to has some code in it that is meant to make the borders disappear - unfortunately, it didn't work for me, and I'm not sure why. So rather than sit through and debug it, I modified that code so that now, instead of modifying the style elements of those tables, it just rips up the child table with the important information and dumps it in the main body of the iFrame. Problem solved. There's still a slight border to the right that I can't get rid of, but if you turn the border displays off it's barely noticeable and I can live with that.

Here's the code if you're interested:

var frameName = 'IFRAME_Name';
var objFrame = document.getElementById(frameName);
var objWindow = document.frames[frameName];
objFrame.allowTransparency=true;
objFrame.onreadystatechange = function ()
{
if (objWindow.document.readyState=='complete')
{
objWindow.document.body.style.backgroundColor='transparent';
if (objWindow.document.getElementsByTagName('BODY')[0]!=null)
{
objWindow.document.getElementsByTagName('BODY')[0].style.padding='0px';
if (objWindow.document.getElementsByTagName('TABLE')[0] != null)
{
if (objWindow.document.getElementsByTagName('TABLE')[0].getElementsByTagName('TD')[0] != null)
{
objWindow.document.getElementsByTagName('BODY')[0].innerHTML = objWindow.document.getElementsByTagName('TABLE')[0].getElementsByTagName('TD')[0].innerHTML;
}
}
}
}
}

No comments: