Hi Nicholas and String,

Go get some information on which container the gadget is running on,
the "standard" undocumented way of doing that was to check the synd
URL parameter using the _args() API function: _args()["synd"]

This works great to find out if the gadget is on iGoogle (value is
'ig'), or if it is in open syndication like on a website (value is
'open'). Unfortunately, some containers do not implement the synd
parameter. On Gmail for instance, we are just getting a 'undefined'
value. You can use this simple gadget to experiment on different
containers:
http://www.ljmsite.com/google/gadgets/tests/get_synd.xml
String suggestion to use the document.referer is a good one (I did not
think of checking this earlier... thanks String!). Basically, for a
generic solution, you will have to use several checks (synd, referer,
and possibly others).

For the gadget iframe width, here again there is no API provided
function for that. I personally use the following function:

function getWidth() {
        if(self.innerHeight) {
                return self.innerWidth;
        }
        else if(document.documentElement &&
document.documentElement.clientHeight) {
                return document.documentElement.clientWidth;
        }
        else if(document.body) {
                return document.body.clientWidth;
        }
        return 0;
}

I reused this code from old, pre-gadget days projects. This might be
overkill, but I feel safe with this code that has worked fine on many
different projets on any browsers.

Jerome

On Mar 18, 1:08 pm, String <[email protected]> wrote:
> On Mar 17, 4:07 pm, Nicholas <[email protected]> wrote:
>
> > I have a gadget that works great on the iGoogle home page. However
> > when you put it on the Gmail page there is much less space available
> > and the gadget looks pretty bad. Is there any way for the gadget to
> > detect properties of the container (size, etc) or detect the type of
> > the container so that it can display itself differently?
>
> Hi Nicholas,
>
> I use code like this to detect container width:
>
> function getWidth() {
>     return Math.max(document.body.scrollWidth,
> document.body.offsetWidth);
>
> };
>
> As for sniffing out the platform, I've had good luck with detecting a
> gadget running on GMail with
>
> if (document.referer.search('//mail.google') > -1) {
>   ... do gmail-specific handling
>
> }
>
> As usual, YMMV, but those snippets work for me.
>
> String
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Gadgets-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to