On Dec 20, 8:36 pm, Michael Hu <[email protected]> wrote:
> Hi, everyone, I am a google gadget newbie.
>
> I created a test gadget in iGoogle, and I defined a function named
> "clear". When I add this function to <input> method onclick, it
> doesn't work! When I changed function name from "clear" to "clean",
> everything just works fine.
>
> I don't know why, could someone explain this?

clear is a method on the document object.  (https://
developer.mozilla.org/en/DOM/document.clear)  The browser is finding
this method before it finds yours.  Since you defined your function
clear in the global scope, you can reference it through the window
object.  See below.

>
> ps: I tested this in Firefox 3.0.5 using GGE
>
> Here is my test gadget code:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
> <ModulePrefs title="Dynamic Height" height="100">
> <Require feature="dynamic-height"/>
> </ModulePrefs>
> <Content type="html"><![CDATA[
> <script type="text/javascript">
> function add(element){
> var html = document.getElementById("container").innerHTML;
> var msg = element.msg.value;
> html += msg + "<br />";
> setContent(html);
>
> gadgets.window.adjustHeight();
>
> }
>
> function clear(){
> setContent("");
>
> }
>
> function setContent(cont){
> document.getElementById("container").innerHTML = cont;}
>
> </script>
>
> <div>
> <form>
> Say:<input name="msg" type="text" /><input type="button" value="Add"
> onclick="add(this.form)" /><br />
> <input type="button" value="Clear" onclick="clear()" />

<input type="button" value="Clear" onclick="window.clear()" />

> </form>
> <div id="container"></div>
> </div>
> ]]></Content>
> </Module>
--~--~---------~--~----~------------~-------~--~----~
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