Archive for March, 2008

Hiding bars in iFrames

Friday, March 28th, 2008

Showing related entities in an iFrame is well known. Sometimes you only want to show the associated view without all the functionality. For example, if you show the activities associated view in an iFrame you get:

Activities_iFrame01

But sometime you only want to show:

Activities_iFrame02

This can be achieved by adding a couple of line to your code to the code for your iFrame:

//hide the Filter bar
if (objWindow.document.all.AppGridFilterSelector!=null) {
objWindow.document.all.AppGridFilterSelector.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[0].style.display='none';
}
//hide the menu bar
if (objWindow.document.all.mnuBar1 !=null) {
objWindow.document.all.mnuBar1.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.style.display='none';
}

With the rest of the code it becomes like this:

//first check if the user is online. If the user is online, than the organization name should be used in the link. Otherwise (if offline) the organisation name should not be used in the link.
if (IsOnline())
{
var org = "/" + ORG_UNIQUE_NAME;
}
else
{
var org = "";
}
//the first part is to hide the borders
var frameName = 'IFRAME_Activities';
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) {
objWindow.document.getElementsByTagName('TABLE')[0].cellPadding='0';
objWindow.document.getElementsByTagName('TABLE')[0].style.border='0px';
}
}
//hide the Filter bar
if (objWindow.document.all.AppGridFilterSelector!=null) {
objWindow.document.all.AppGridFilterSelector.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[0].style.display='none';
}
//hide the menu bar
if (objWindow.document.all.mnuBar1 !=null) {
objWindow.document.all.mnuBar1.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.style.display='none';
}
}
//setting the contents of the iframe
var navFrame2;
navFrame2 =
document.all.navActivities;
var navWindow = document.frames['IFRAME_Activities_d'];
//and checking if the entity has been saved, nor quick create nor bulk edit is.
if (crmForm.FormType==1  || crmForm.FormType == 5 || crmForm.FormType == 6)
{
document.all.IFRAME_Activities.src="about:blank";
}
else
{
if (navFrame2 != null)
{
document.all.IFRAME_Activities.src= org + "/sfa/accts/areas.aspx?oId=" +
crmForm.ObjectId +"&oType="+crmForm.ObjectTypeCode+"&security=852023&tabSet=areaActivities";
navFrame2.name = navFrame2.id;
}
else{
alert("Page Not Found");
}
}