In response to a comment on the last Dashcode tutorial, I’ll quickly show you how to create a button on your widget that will open a URL in your browser when clicked.
If you haven’t already, open any type of project in Dashcode. Now, drag any type of button (I chose a glass button in my example) and place it on your widget:
You can double click the button to change it’s caption, then right click it and choose *Events* → *onclick*
A dialog will ask you what name your onclick function should have. Enter anything that only has alphanumeric characters and underscores (no spaces, special characters, …):
Once you click *Add*, you’ll be taken to the source code editor, and a function like this will greet you:
Note that the function name will probably not be the same as in my image, it reflects what you just typed in the dialog box. Now we only need to type a few lines of code to complete our button:
function goToMyWebsite()
{
if ( window.widget )
{
widget.openURL( “http://www.google.com” );
return false;
}
}
And that’s about it, change the URL to reflect whatever website you want to open and you’re done!








Ecology: The Experimental Analysis of Distribution and Abundance (6th Edition)
Ecology



















Hey
Thanks for the tutorials, they’re great.
I was wondering if you could help me with something. I want to do a widget showing a radar picture from a site. But I cant figure out how to insert a url, and make it show the picture from the url.
Any help would be much appreciated.
Thanks, I was wondering how to do this!
One thing: how can I make it so that when I mouse over the link the cursor changes to the usual URL hand? I’m not using a button, I’m making an image of the site logo be the link, so I’d like to make it more apparent to the user that the image is also a link.
Thanks again for the great Dashcode help.