Javascript in Google Gadgets
I'm writing a simple gadget to use with google calendar. I'm usin开发者_StackOverflow中文版g iGoogle to test. However, no matter what I do I cannot seem to get javascript to run. Can anyone point me in the right direction? Thanks in advance
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="hello world example" />
<Content type="html"><![CDATA[ <div style="text-align:center"><a
id="Riggs" title="My Photo Album" target="_blank"
href="http://picasaweb.google.com/doc.examples/ShelfBoy">
<img border="0" alt="Photo" src="http://doc.examples.googlepages.com/Riggsie-OP.jpg"
title="Click Here."></a>
</div>
<script type="text/javascript">
alert('hi');
</script>
]]></Content>
</Module>
Actually, the code exactly as you have it works for me, so I am not sure what problem you are having.
I have a sample on JsFiddle so you can see it in action.
If it does not show up with an alert box that says, "hi", then all I can guess is that your browser does not have Javascript enabled or is blocking alert messages.
If you want to test it yourself, you can use the Google Gadgets Editor.
精彩评论