google.load causes page refresh [Feed API]

174 views
Skip to first unread message

Andy

unread,
May 3, 2007, 8:30:40 AM5/3/07
to Google AJAX API
I want to load the Google API only on demand (i.e. not embed it in the
page HTML; but rather add it later, using Javascript).
For the sake of example, I will use a setTimeout for this (see code
below). I have verified it is not actually caused by setTimeout.

What happens is, when I eventually call google.load, the page begins
to refresh (goes white).
The status bar says, "Transferring data from www.google.com"

It's very frustrating!


My page:

<html>
<head>

<script>

// Create a callback function that will load the Google JS
var f1 = function(){
// Load the script [THIS IS FINE, IT LOADS]
var el = document.getElementsByTagName("HEAD")[0];
var elScript = document.createElement("SCRIPT");
elScript.setAttribute("src", "http://www.google.com/jsapi?key=MYKEY");
el.appendChild( elScript );

// After Google JS loaded, try to load Feeds:
var f2 = function(){
google.load("feeds", "1"); // When this executes, the page refreshes
saying "Transferring data from google..."
}
setTimeout( f2, 2000 );

}
setTimeout( f1, 1000 );

</script>

</head>

<body>
</body>
</html>

mhl

unread,
May 4, 2007, 2:02:11 AM5/4/07
to Google AJAX API
google.load() is designed to be called while the document is still
under construction and therefore uses document.write for a few things.
You are calling this when the page is fully constructed. Calling
document.write at that time will create a new page which is not what
you want.

We currently do not support the dynamic loading model that you are
trying to make work.

Reply all
Reply to author
Forward
0 new messages