Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Central

functions in HTML vs. functions in JavaScript

Author Message
andrethegiant



Joined: 08 May 2005
Posts: 78

Posted: Mon Jun 13, 2005 - 11:59 pm    Post subject: functions in HTML vs. functions in JavaScript Reply with quote

this is weird. I tried two of what I thought were the same things, but only one worked. In HTML, I wrote

Quote:
<img src="file:///System/Library/WidgetResources/ibutton/black_i.png" onmousedown="showbackside()" />


and my widget flips beautifully (i know the showbackside function works, that's not the problem). However, I then deleted that and wrote

Quote:
<script>document.write("<img src=file:///System/Library/WidgetResources/ibutton/black_i.png onmousedown=\"showbackside()\" />");</script>


and the little i button came up, but when i clicked it, it paused for a few seconds and then did nothing!

Can anyone solve my problem?
View user's profile Send private message Send e-mail Widgets
JohnGaver



Joined: 17 May 2005
Posts: 20
Location: Texas

Posted: Tue Jun 14, 2005 - 2:42 pm    Post subject: Flippin' Widgets Reply with quote

I'm not sure what you are doing, but it looks like you are not using CSS to place your flippie thingie. But, if you are bound and determined to do it in the html file, it looks like you missed some quotes. Try this.

Quote:
<script>document.write("<img src=\"file:///System/Library/WidgetResources/ibutton/black_i.png\" onmousedown=\"showbackside()\" />");</script>


Having said that, I would suggest that you don't try to do it all inside the HTML file. Put the JS in its own file and call it in the head section, like this.

Quote:
<script type='text/javascript' src='javascript.js' charset='utf-8'/>


Then place your elements on the widget, using named CSS layers.

Then, you can use GetElementById to place elements inside a particular named layer or span.

If you use that method, Apple has already done a lot of the work for you. Just look at the source of WorldClock.js in the World Clock widget or any other Apple widget. You can just copy and paste most of the flippie stuff. The key is that you need to use THEIR names for the CSS styles in YOUR html, or adjust THEIR JS to match YOUR styles.

Good luck.
View user's profile Send private message Send e-mail Visit poster's website Widgets
andrethegiant



Joined: 08 May 2005
Posts: 78

Posted: Tue Jun 14, 2005 - 9:26 pm    Post subject: Reply with quote

Thanks for replying. FYI, I do use css and have my javascript in another file, but I didn't state that before. I added the quotes and looked at it even more, and it all looks right, but it still doesn't work.

I think the problem is because the javascript "i" is in a function called update(). When i hit "done" on the back (the widget starts out on the back) it uses showfrontside(), which includes update(). I don't know if that has anything to do with it.

I don't know if any of you understand, because it's very hard to explain. I think i'm going to upload my widget in a preview version so everyone can see the source.

Thanks
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group