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

widget.openURL does not work?

Author Message
Magicj



Joined: 18 Feb 2006
Posts: 4
Location: Philadelphia

Posted: Sat Feb 18, 2006 - 9:57 pm    Post subject: widget.openURL does not work? Reply with quote

I'm just getting into this widget stuff and I would like to include a link to a web page. All the faq's say to use "widget.openURL." And several widgets I have downloade and examined usethis. But it does not work. In my script OR any of the ones I have downloaded such as the oldfaithfull widget or the halifax widget. The links are there, but nothing happens. I thought maybe I may have turned something off. But I have tried this on two different Macs and it just does not work. Any thought?

thanks.
View user's profile Send private message Visit poster's website Widgets
gurth



Joined: 21 Jul 2005
Posts: 47
Location: Netherlands

Posted: Tue Feb 21, 2006 - 5:27 am    Post subject: Re: widget.openURL does not work? Reply with quote

Have you enabled network access in the Info.plist file for your widget? That is, check that the following lines are in it:
Code:
<key>AllowNetworkAccess</key>
<true/>
View user's profile Send private message Send e-mail Widgets
Magicj



Joined: 18 Feb 2006
Posts: 4
Location: Philadelphia

Posted: Fri Feb 24, 2006 - 4:28 pm    Post subject: Reply with quote

Yes, But what I'm saying is it does not work in ANY widget that I have downloaded and tried.
View user's profile Send private message Visit poster's website Widgets
Magicj



Joined: 18 Feb 2006
Posts: 4
Location: Philadelphia

Posted: Sat Feb 25, 2006 - 9:03 am    Post subject: when is a widget not a widget? Reply with quote

I've done a little more digging. It looks like some widgets are working others are not. I've added if (window.widget) {or is it "if(widget), i've see both.) and it appears that for the widgets that do not work, they do not think they are widgets. The code protected by the "if (window.widget) is not being executited. That would explaine why openURL is not working. But now I'm wondering why these widgets do not "know" they are widgets. Any ideas??

thanks
View user's profile Send private message Visit poster's website Widgets
jtbandes



Joined: 17 Jun 2005
Posts: 269
Location: Oregon

Posted: Sat Feb 25, 2006 - 10:04 am    Post subject: Reply with quote

Are you using Dashboard?
View user's profile Send private message Send e-mail Widgets
purvisa



Joined: 21 Jul 2005
Posts: 182
Location: Kirkland, WA

Posted: Sun Feb 26, 2006 - 2:41 am    Post subject: Reply with quote

jtbandes summed it up perhaps a little too succinctly. If you are ussing Dashboard, most behaviors will be just as in Safari. However, certain things cannot act properly unless they know how to act under certain circumstances.

Dori took me to task over the use (or my lack, at the time, of use) of DTDs. Many things could result in problems, of course, and I would suggest you do one of two things by way of playing sleuth:

1) Find a widget for which the code works and check its syntax. Make any changes, however small, to bring your code in line.

OR

2) (I suggest this one) Create a dummy widget that has no code but the very minimum needed to get your functionality. Tweak thoroughly until functionality is achieved. Smile and migrate code to the real thing.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger Widgets
Dori



Joined: 27 Jan 2005
Posts: 47
Location: Healdsburg, CA

Posted: Sun Feb 26, 2006 - 3:44 am    Post subject: Reply with quote

purvisa wrote:
Dori took me to task over the use (or my lack, at the time, of use) of DTDs.


Just to be clear: I think that that was mostly regarding problems with layout and rendering. If you're ever having problems with getting things to show up just where you want them, making sure your HTML and CSS validate (which requires a doctype) is always a good place to start.

I don't know that a doctype will help much with scripting-related issues, but then, it can't hurt, either.
View user's profile Send private message Visit poster's website AIM Address Widgets
purvisa



Joined: 21 Jul 2005
Posts: 182
Location: Kirkland, WA

Posted: Sun Feb 26, 2006 - 4:44 am    Post subject: Reply with quote

I have noticed that sometimes the Javascript behaves a little differently in browsers than in Dashboard. This seems a little odd, given that they use the same set of standards.

In any case, Dori was right (I use DTDs in my widgets now).
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger Widgets
Magicj



Joined: 18 Feb 2006
Posts: 4
Location: Philadelphia

Posted: Sun Feb 26, 2006 - 10:03 am    Post subject: Ya just can't trust code you steal. Reply with quote

I had started with a widget that I downloaded from Apple's dashboard site, that I foolishly thought worked: The Halifax Harbor Webcam. And I started to modify that. It now appears to me that this is a poorly done conversion from a Yahoo widget. To refresh the image this widget used:

function reloadImage() {
// Reloads widget (and image).
history.go(0);
if (debug) alert('DEBUG: reloading');
}

I found from else where on this site (Thank You!) that the widget object only exists the first time the widget is loaded. " history.go(0)" reloads the entire widget and thus "widget" no longer exists. Therefore (window.widget) would be false and thus widget.openURL would not work.

The reload I came up with is:

function reloadImage() {
// Reloads and image
// history.go(0);
timer = window.setTimeout('reloadImage()', reloadInterval);
var uniq;
// Sets and displays time, link.
var time = new Date();
uniq = time.getTime();
var sec = time.getUTCSeconds();
if (sec < 10) sec = '0' + sec;

var min = time.getUTCMinutes();
if (min < 10) min = '0' + min;

var hur = time.getUTCHours();
if (hur < 7) hur = 24 + hur;
hur = hur - 4;
if (hur < 10) hur = '0' + hur;

document.images.theimage.src = webcam + "?" + uniq ;

if (window.widget) {
document.getElementById('links').innerHTML = hometext + hur + ':' + min + ':' + sec + '. <span class="a" onClick="widget.openURL(' + homepage + ')">' + hometitle + '</span>';
}
if (debug) alert('DEBUG: reloading');
}

This reloads only the image (and up dates the title bar) pesereving "widget" and thus the link with widget.openURL works just fine.

Thank you All for your help and suggestions.

Any one have any suggestions for converting this to a Yahoo widget so my windows based friends can use this as well?
View user's profile Send private message Visit poster's website Widgets
purvisa



Joined: 21 Jul 2005
Posts: 182
Location: Kirkland, WA

Posted: Sun Feb 26, 2006 - 1:42 pm    Post subject: Reply with quote

Ew! That's bad no matter how it came into existence. Good catch.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger 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