function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike @ PartnersMike @ Partners 

Custom tab help.

I have a custom tab that calls a page on my server. I need to resize the tabs iframe using javascript so i dont get two scroll bars. The problem is every code i try i get "Error: uncaught exception: Permission denied to get property ..." as an error. Is there any way to do this?
Thanks for the help,
Mike
Ron HessRon Hess
can you show what your code looks like to resize the parent iframe ?

here is some that I found laying around :

function resizeIframe() {
    var iframe = parent.document.getElementById(sControlId);
    if(iframe != undefined){
        var height = document.body.scrollHeight;
        iframe.style.height = height + 'px';
    }
}


but, you also need the sControlId, so try this:

        var scontrolUrl = "{!Scontrol.URL}";
        var index = scontrolUrl.indexOf("file=");
        sControlId = scontrolUrl.substring(index + 5);

This method relys on knowing the name of the parent iframe, so may change in the future, but you get the idea, there are other ways to get the parent element.


Mike @ PartnersMike @ Partners
Here is the script that i have on my page hosted on my server.

Code:
function ResizeParentiFrame(){
var iframe = parent.document.getElementById("itarget");
 if (iframe) { var height = document.body.scrollHeight; iframe.height = height+'px'; } }


I noticed on your code that you were referring to a sControl. i am using a custom tab that links to my server. I dont have a sControl ID to work with. Any ideas? I still am getting 'Error: uncaught exception: Permission denied to get property HTMLDocument.getElementById'

It almost seems that the javascript on my pages (saved on my servers) cant access the pages on salesforces servers. Is there anyway around this?

Thank you for the help.
Mike
Ron HessRon Hess
I see, your frame is in a different domain, so no, you can't resize a frame in a different domain, basicaly this is the cross-domain problem.

you can configure (in salesforce ) your web tab to open a large window, then your app won't hit the bottom of the parent frame, so you won't have that pesky second scroll bar ? no?