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 Development

how do I make clickable links in widgets?

Author Message
me94501



Joined: 15 Apr 2005
Posts: 1
Location: Bay Area, CA

Posted: Fri Apr 15, 2005 - 2:19 pm    Post subject: how do I make clickable links in widgets? Reply with quote

I work for a small tech news site (dtgeeks.com) and I'm currently making a simple widget to display the most recent news headlines (via the site's RSS feed). I got it to display the links just fine, but making them clickable is another matter altogether. How would I go about doing this?

I really have no javascript knowledge, though I am pretty familiar with CSS, XHTML, and a little PHP. If I decide to make more widgets beyond this one, I'd probably want to learn javascript.

Anyway, here it is: http://homepage.mac.com/me_94501/DTNewsB.zip Yes, I know there is a cosmetic bug in there. That's the least of my worries.

If you have any ideas, resources, or code you want to throw my way, let me know. I'd appreciate it. Smile
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
pm
Administrator


Joined: 24 Aug 2004
Posts: 398

Posted: Fri Apr 15, 2005 - 3:23 pm    Post subject: Reply with quote

I don't yet have access to Dashboard so I can't be of much help. However, the links do seem to work in Safari, perhaps a Dashboard bug?
View user's profile Send private message Send e-mail Widgets
macmanluke



Joined: 15 Apr 2005
Posts: 16
Location: SA

Posted: Fri Apr 15, 2005 - 8:23 pm    Post subject: Reply with quote

There is a special peice code you have to use i cant remember what it is at the moment

Ill find it then get back to you
View user's profile Send private message Widgets
masto



Joined: 08 Apr 2005
Posts: 4

Posted: Sat Apr 16, 2005 - 1:51 pm    Post subject: Reply with quote

This is covered in the documentation.
View user's profile Send private message Send e-mail Visit poster's website Widgets
macmanluke



Joined: 15 Apr 2005
Posts: 16
Location: SA

Posted: Sat Apr 16, 2005 - 9:24 pm    Post subject: Reply with quote

Where can i find that?
View user's profile Send private message Widgets
lando



Joined: 25 Mar 2005
Posts: 7

Posted: Sun Apr 17, 2005 - 1:31 pm    Post subject: Reply with quote

you want widget.openURL(...);

When generating href tags, I use a function like this:

Code:
function wrapURL (theURL) {
     if (window.widget) {
          theURL = "javascript:widget.openURL('" + theURL + "');";
     }
     return theURL;
}


This will make the HREF a call to widget.openURL in a widget, or leave it untouched in Safari, allowing the link to be followed in either case. The Dashboard docs are in /Developer/ADC Reference Library/documentation/AppleApplications/
View user's profile Send private message Widgets
macmanluke



Joined: 15 Apr 2005
Posts: 16
Location: SA

Posted: Wed Apr 20, 2005 - 2:39 am    Post subject: Reply with quote

When using that method do you have to add the function to the onclick?
View user's profile Send private message Widgets
JohnnyBender



Joined: 19 Apr 2005
Posts: 17
Location: Toronto, Canada

Posted: Wed Apr 20, 2005 - 9:22 am    Post subject: Reply with quote

lando wrote:
you want widget.openURL(...);

When generating href tags, I use a function like this:

function wrapURL (theURL) {
if (window.widget) {
theURL = "javascript:widget.openURL('" + theURL + "');";
}
return theURL;
}

This will make the HREF a call to widget.openURL in a widget, or leave it untouched in Safari, allowing the link to be followed in either case. The Dashboard docs are in /Developer/ADC Reference Library/documentation/AppleApplications/


I tried calling this function from an img tag and it didn't work.
<img src="image.jpg" onclick="wrapURL()">

What am I doing wrong?
View user's profile Send private message Send e-mail Visit poster's website Widgets
macmanluke



Joined: 15 Apr 2005
Posts: 16
Location: SA

Posted: Wed Apr 20, 2005 - 9:25 am    Post subject: Reply with quote

the url needs to be inside the brackets eg

<img src="logo.gif" onclick="WrapURL(http://www.widgetdeveloper.com)">
View user's profile Send private message Widgets
JohnnyBender



Joined: 19 Apr 2005
Posts: 17
Location: Toronto, Canada

Posted: Wed Apr 20, 2005 - 9:50 am    Post subject: Reply with quote

macmanluke wrote:
the url needs to be inside the brackets eg

<img src="logo.gif" onclick="WrapURL(http://www.widgetdeveloper.com)">


I've tried the following and it does nothing when I click ...

Code:
function wrapURL (theURL) {
   if (window.widget) {
      theURL = "javascript:widget.openURL('" + theURL + "');";
   }
   return theURL;
}
<a href="javascript:wrapURL(http://www.apple.com)"><img src="image.jpg"></a>

What am I doing wrong?
View user's profile Send private message Send e-mail Visit poster's website Widgets
dE



Joined: 14 Apr 2005
Posts: 7

Posted: Thu Apr 21, 2005 - 5:44 am    Post subject: Reply with quote

Hi.

Quote:
Code:
<a href="javascript:wrapURL(http://www.apple.com)"><img src="image.jpg"></a>


What am I doing wrong?


Code:
<a href="javascript:wrapURL('http://www.apple.com')"><img src="image.jpg"></a>


Use 'domain' because the URL is a string.

greetings
Dirk Einecke
View user's profile Send private message Send e-mail Visit poster's website Widgets
BillinSoBe



Joined: 24 Apr 2005
Posts: 1

Posted: Tue Apr 26, 2005 - 6:35 pm    Post subject: Sorry! Reply with quote

Sorry I'm new to Javascript and I'm still having a problem with this... could someone lend a hand.

Admentor is running as expected. I see the ad but I can't click on the URL in Dashboard. Safari works as expected.

Many Thanx!


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

</head>
<body>
<table width="259" border="0" cellspacing="0" cellpadding="0" background="images/Default.png" height="273">
<tr>
<td>

<script language="JavaScript">
if (window.widget) {
widget.onhide = onhide;
widget.onshow = onshow;
}

function onshow() {
if (timerInterval == null) {
timerInterval = setInterval("updateTime(true);", 1000);
}
}

function onhide() {
if (timerInterval != null) {
clearInterval(timerInterval);
timerInterval = null;
}
}



function wrapURL (theURL) {
if (window.widget) {
theURL = "javascript:widget.openURL('" + theURL + "');";
}
return theURL;
}
</script>


<!------- AdMentor Ad code ------------->
<script language="JavaScript">
var code = '';
var now = new Date();
var nIndex = now.getTime();
document.write('<s' + 'cript src="http://www.justcircuit.com/admentor/scriptinject.asp?F=30&Z=23&N=1&nocache=' + nIndex + '">');
document.write('</' + 's' + 'cript>');
</script>
<script language="JavaScript">document.write(code);</script>
<div align="center">
<noscript>
<a href="javascript:wrapURL('http://www.justcircuit.com/admentor/adclick.asp?F=30&Z=23&N=1')"><img border="0" src="http://www.justcircuit.com/admentor/adserve.asp?F=30&Z=23&N=1"></a>
</noscript>
</div>
<!--------- End AdMentor Ad code --------------->
</td>
</tr>
</table>
</body>
</html>

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