<link href="http://www.google.com/uds/css/gsearch.css" type="text/css"
rel="stylesheet"/>
<script
src="http://www.google.com/uds/api?file=uds.js&v=0.1&key=CHANGE_YOURKEY"
type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
//<![CDATA[
function OnLoad() {
// Create a search control
var searchControl = new GSearchControl();
var options = new GsearcherOptions();
options.setRoot(document.getElementById("somewhere_else"));
searchControl.addSearcher(new GwebSearch(),options);
searchControl.addSearcher(new GblogSearch());
searchControl.draw(document.getElementById("searchcontrol"));
searchControl.execute("Google");
}
//]]>
</script>
<div id="somewhere_else"></div>
<div id="searchcontrol"></div>
<script type="text/javascript">OnLoad()</script>
but this didn't work.
<link href="http://www.google.com/uds/css/gsearch.css" type="text/css"
rel="stylesheet"/>
<script
src="http://www.google.com/uds/api?file=uds.js&v=0.1&key=CHANGE_YOURKEY"
type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
//<![CDATA[
function OnLoad() {
// Create a search control
var searchControl = new GSearchControl();
var options = new GsearcherOptions();
options.setRoot(document.getElementById("somewhere_else"));
searchControl.addSearcher(new GwebSearch(),options);
searchControl.addSearcher(new GblogSearch());
searchControl.draw(document.getElementById("searchcontrol"));
searchControl.execute("Google");
}
//]]>
</script>
<div id="somewhere_else"/>
<div id="searchcontrol"/>
<script type="text/javascript">OnLoad()</script>
I have seen this problem from time to time when dynamic pages use
.innerHTML to squirt in a template.
In this case, there are situations where IE and Firefox handle empty,
named divs differently:
<div/> vs. <div></div>
In some cases, the div is lost, but what I have seen more often is that
adjacent divs become related not as siblings, but as parent child. This
does not happen for pages that your browser loads directly, but in the
case of blogger, you are working in a dynamic environment that you do
not control so you need to be extra safe.
The best way for you to structure your code in this environment is for
you to write your div's as:
<div id="somewhere_else">web results go here</div>
<div id ="searchcontrol">search control goes here</div>
I have never seen either browser process the above wrong no matter how
the html is loaded. You don't see this used in any of our samples
because they are all first level html pages loaded directly by the
browser.
When you have a static page that the browser is fetching or loading
your script above will work fine targetting either <div/> or
<div></div>, BUT if the page being loaded is a template, and the
application write a string of innerHTML into that template, I have seen
the single tage empty div just plain disappear, or worse, become a
child of a nearby element.
Given that you are not in control of the environment, the safest way
for you to write this is:
<div id="somewhere_else">web results will end up here</div>
<div id="searchcontrol">search results go here</div>