[google-chrome-frame:1118] Chrome Frame Detection doesn't work

1,069 views
Skip to first unread message

Rich Bradshaw

unread,
May 2, 2010, 4:42:23 AM5/2/10
to Google-chrome-frame
I've copied the demo code into a jsbin document here: http://jsbin.com/atifu4

Rather than prompting the user to install CF (or whatever it's meant
to do!), it just comes up with a variety of errors in IE:
"'document.body' is null or not an object", or "'null' is null or not
an object".

Any ideas? I've tried in IE8 only currently.

--
You received this message because you are subscribed to the Google Groups "Google-chrome-frame" group.
To post to this group, send email to google-ch...@googlegroups.com.
To unsubscribe from this group, send email to google-chrome-f...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-chrome-frame?hl=en.

Alex Russell

unread,
May 4, 2010, 2:39:15 PM5/4/10
to google-ch...@googlegroups.com
IE doesn't like trailing commas on the last element in an object
literal. You have:

CFInstall.check({
mode: "overlay",
});

Which should just be:

CFInstall.check({
mode: "overlay" // note the lack of comma
});

Regards

JPSykes

unread,
Jun 11, 2010, 3:57:01 PM6/11/10
to Google-chrome-frame
I'm getting a similar bug.

This is in my head:

<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/chrome-frame/1/CFInstall.js"></script>

<style>
/*
CSS rules to use for styling the overlay:
.chromeFrameOverlayContent
.chromeFrameOverlayContent iframe
.chromeFrameOverlayCloseBar
.chromeFrameOverlayUnderlay
*/
</style>

<script>
CFInstall.check({
mode: "overlay"
});
</script>

Hit it with IE8 and I'm getting:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/
4.0)
Timestamp: Fri, 11 Jun 2010 19:56:39 UTC


Message: 'null' is null or not an object
Line: 248
Char: 7
Code: 0
URI: http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.js


On May 4,
2:39 pm, Alex Russell <slightly...@google.com> wrote:
> IE doesn't like trailing commas on the last element in an object
> literal. You have:
>
>    CFInstall.check({
>      mode: "overlay",
>    });
>
> Which should just be:
>
>    CFInstall.check({
>      mode: "overlay" // note the lack of comma
>    });
>
> Regards
>
>
>
> On Sun, May 2, 2010 at 1:42 AM, Rich Bradshaw <rich.brads...@gmail.com> wrote:
> > I've copied the demo code into a jsbin document here:http://jsbin.com/atifu4
>
> > Rather than prompting the user to install CF  (or whatever it's meant
> > to do!), it just comes up with a variety of errors in IE:
> > "'document.body' isnullor not an object", or "'null' isnullor not
> > an object".
>
> > Any ideas? I've tried in IE8 only currently.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Google-chrome-frame" group.
> > To post to this group, send email to google-ch...@googlegroups.com.
> > To unsubscribe from this group, send email to google-chrome-f...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/google-chrome-frame?hl=en.

JPSykes

unread,
Jun 11, 2010, 4:21:18 PM6/11/10
to Google-chrome-frame
Looks like it's because you have the CFinstall.check in the head tag
so it runs before the body has finished loading.

If you add the cfinstall script at the bottom of the page right above
the closing </body> the error will go away.


On May 4, 2:39 pm, Alex Russell <slightly...@google.com> wrote:
> IE doesn't like trailing commas on the last element in an object
> literal. You have:
>
>    CFInstall.check({
>      mode: "overlay",
>    });
>
> Which should just be:
>
>    CFInstall.check({
>      mode: "overlay" // note the lack of comma
>    });
>
> Regards
>
>
>
>
>
> On Sun, May 2, 2010 at 1:42 AM, Rich Bradshaw <rich.brads...@gmail.com> wrote:
> > I've copied the demo code into a jsbin document here:http://jsbin.com/atifu4
>
> > Rather than prompting the user to install CF  (or whatever it's meant
> > to do!), it just comes up with a variety of errors in IE:
> > "'document.body' isnullor not an object", or "'null' isnullor not
> > an object".
>
> > Any ideas? I've tried in IE8 only currently.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Google-chrome-frame" group.
> > To post to this group, send email to google-ch...@googlegroups.com.
> > To unsubscribe from this group, send email to google-chrome-f...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/google-chrome-frame?hl=en.

Sig Weber

unread,
Jun 12, 2010, 7:53:36 AM6/12/10
to Google-chrome-frame
On Jun 11, 10:21 pm, JPSykes <sykes....@gmail.com> wrote:
> Looks like it's because you have the CFinstall.check in the head tag
> so it runs before the body has finished loading.

Although it has been part of the HTML 4.01 standard for many years now
I am not 100% sure if all Web browser vendors have implemented it yet,
but you can defer loading script as described here:

http://www.quirksmode.org/js/placejs.html

That way you can create a reusable module for your Website, like I
did, to include it in the HEAD section of a CMS template.

Here's the slightly overhauled code example from
http://www.chromium.org/developers/how-tos/chrome-frame-getting-started:

=== code ===
<!--[if IE]>
<script language="javascript" type="text/javascript" src="http://
ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></
script>

<style>
/* CSS rules to use for styling the overlay:
.chromeFrameOverlayContent
.chromeFrameOverlayContent iframe
.chromeFrameOverlayCloseBar
.chromeFrameOverlayUnderlay
*/
</style>

<script language="javascript" type="text/javascript" defer>
CFInstall.check({mode: "overlay", destination: "http://
www.example.com"});
</script>
<![endif]-->
=== code ===

Another improvement in the above code snippet is the use of an
Internet Explorer conditional comment (see
http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx) to
prevent non-IE browsers from even looking at the JavaScript which will
speed up page load for them (no check for ActiveXObject etc.).

@CF team: would be great if somebody could update the CF Developer
Guide page with this. Thanks!

Cheers,

Sig

Alex Russell

unread,
Jun 13, 2010, 12:53:31 AM6/13/10
to google-ch...@googlegroups.com

I added a conditional comment and an onload handler to the second
example to deal with the potential race. Let me know if you think it
can be clearer.

Regards

Sig Weber

unread,
Jun 13, 2010, 3:46:54 PM6/13/10
to Google-chrome-frame
> On Jun 13, 6:53 am, Alex Russell <slightly...@google.com> wrote:
> I added a conditional comment and an onload handler to the second
> example to deal with the potential race. Let me know if you think it
> can be clearer.

Perfect (even better than mine by using attachEvent). Thanks!
Reply all
Reply to author
Forward
0 new messages