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

How to open a Safari Window?!

Author Message
rookie



Joined: 08 May 2005
Posts: 1
Location: switzerland

Posted: Sun May 08, 2005 - 10:52 am    Post subject: How to open a Safari Window?! Reply with quote

hi,
im trying to make a small search-widget for the local TV-Programm here in switzerland.

im almoust finished, with design, formular and so on. in safari, the widget works without problems. you can test it here: http://www.twirl.ch/dashboard/tv/tv.htm

but when opened in dashboard, the results don't open in a new safari window.
i know its because of folloing tag:
Code:
<form action="http://www.tvstar.ch/tv_suche.asp" method="post" name="frTvSuche" class="Stil1" ID="frTvSuche" [color=red]target="_blank">[/color]


there should be written something like "”widget.openURL" as seen on the Apple Developer Dashboard Programming Guide.

But i'm not really a pro in programming these things, so im asking you: if you could please have a short view on the code an help me if you can.

thank you!

the widget can be seen and downloaded here
View user's profile Send private message Send e-mail Visit poster's website Widgets
kingmob



Joined: 07 May 2005
Posts: 68
Location: Vienna

Posted: Sun May 08, 2005 - 7:19 pm    Post subject: Reply with quote

Hi rookie,

the basic syntax to open an URL is
Code:
widget.openURL('http://foo.bar.com');


To use it, you need to grab the values from your form into javascript and then merge them together to create the final URL you want to call. I had a quick look at your code, and it should look like this:

Code:
<html>
<head>
<script type="text/javascript">
function getTvInfo () {
var strTVSuchtext = window.document.frTvSuche.strTVSuchtext.value;
var strTVSendezeit = window.document.frTvSuche.strTVSendezeit.value;
...
widget.openURL('http://www.tvstar.ch/tv_suche.asp?TVSuchtext' + strTVSuchtext + '&TVSendezeit=' + strTVSendezeit + ...');
}
</script>
</head>
<html>
<form action="" onSubmit="getTvInfo()" name="frTvSuche">
...
</form>
</body>
</html>


explanation: you take the values of your form fields by assigning the value of window.document.NAME_OF_FORM.NAME_OF_FIELD.value to a variable. after you have the info, you call widget.openURL with the search URL and all the parameters you want to pass to it. In order you make your form use the JavaScript code, you use the onSubmit="FUNCTION_NAME()" string.

I guess that's it. If you need any further help, please reply. Ah, since you are Swiss, you should have a look at this thread on how to deal with umlauts properly. Grüezi Wink
_________________
I have no .sig and I must post.
View user's profile Send private message Send e-mail Visit poster's website AIM Address ICQ NumberWidgets
orageux



Joined: 18 May 2005
Posts: 1
Location: CA

Posted: Wed May 18, 2005 - 1:07 pm    Post subject: How to open a window in Safari Reply with quote

I believe this post is the answer to a problem I am having building a widget that access my site and finds information based on values that are selected in the widget. However, I am seeing inconsistancies that I don't have enough background in javascript to determine what is correct.

The original form action as posted was:
<form action="http://www.tvstar.ch/tv_suche.asp" method="post" name="frTvSuche" class="Stil1" ID="frTvSuche" target="_blank">
followed by form fields etc.

The solution suggested by kingmob (bless you, sir) was to take the values being passed by the form and turn them into variable with I understnad, but there was no mention in the sample of whether hidden values need to be treated this way also. That is my question. Thanks!

P. S. I have read most of the OpenURL posts on this site and not one of them has mentioned the issue of when you try to do anything outside of the widget, you are supposed to post that request for access outside of the widget into the info.plist for that file as per Security protocols in the Dashboard handbook or it won't work. Why is nobody mentioning this?
View user's profile Send private message Send e-mail Visit poster's website Widgets
kingmob



Joined: 07 May 2005
Posts: 68
Location: Vienna

Posted: Wed May 18, 2005 - 1:49 pm    Post subject: Re: How to open a window in Safari Reply with quote

orageux wrote:

The solution suggested by kingmob (bless you, sir)


Why, thank you! Very Happy

orageux wrote:
was to take the values being passed by the form and turn them into variable with I understnad, but there was no mention in the sample of whether hidden values need to be treated this way also. That is my question. Thanks!


Yes, you have to treat hidden values in the same way. First grab then, then pass them on.

orageux wrote:

P. S. I have read most of the OpenURL posts on this site and not one of them has mentioned the issue of when you try to do anything outside of the widget, you are supposed to post that request for access outside of the widget into the info.plist for that file as per Security protocols in the Dashboard handbook or it won't work. Why is nobody mentioning this?


Because it's in the Dashboard Reference Wink
_________________
I have no .sig and I must post.
View user's profile Send private message Send e-mail Visit poster's website AIM Address ICQ NumberWidgets
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