"Loading" modal and navigator.notification onclick of external link

314 views
Skip to first unread message

Jon

unread,
Sep 6, 2010, 10:58:25 AM9/6/10
to phonegap
Hi all,

Within my phonegap app (using html files), one of my links will not
open a local file, but will instead open an external URL. I have
managed to stop it opening in Safari by changing PhoneGapAppDelegate.m
but what I would also like is for a "Loading, please wait" modal to
popup when the user clicks the link and for the navigator.notification
to run in the taskbar. How can I achieve this?

Thanks

Jon

Giacomo Balli

unread,
Sep 6, 2010, 4:42:20 PM9/6/10
to phonegap
navigator.notification.loadingStart()
navigator.notification.activityStart()
is this what you're looking for?

Jon

unread,
Sep 6, 2010, 6:01:32 PM9/6/10
to phonegap
Yes, but at the risk of sounding stupid, where do I use that to
achieve what I need?

Giacomo Balli

unread,
Sep 6, 2010, 6:11:40 PM9/6/10
to phonegap
just insert it whenever you want it Start and then place a loadingStop
when you want it to Stop.
Otherwise use the built-in timer. check the documentation for details.

Jon

unread,
Sep 7, 2010, 6:25:40 AM9/7/10
to phonegap
I've looked through the documentation but can't see anything that
helps me. Basically I want something like:

<a href="javascript:doThis();">Go here</a>

function doThis() {
navigator.notification.loadingStart()
window.location.href = 'http://www.google.co.uk';
return false;
navigator.notification.loadingStop()
}

But when I try this, it does nothing. Obviously if I remove the
navigator bits then the rest of it works fine (it goes to google).

What am I missing?

Thanks

Jon

Marcus Wilhelm

unread,
Sep 7, 2010, 7:55:04 AM9/7/10
to Jon Winterburn, phon...@googlegroups.com
A javascript solution for this is not possible - since an external link will unload your javascript phonegap application. What do you want to do with external links?


regards
Marcus




On 07.09.2010, at 13:08, Jon Winterburn wrote:

Not sure I fully understand you. So how do I achieve the desired result? I just want it so when the user clicks an external link, the loader informs them what is happening - a bit like this article:

http://nachbaur.com/blog/telling-your-user-that-a-phonegap-application-is-busy


On Tue, Sep 7, 2010 at 11:34 AM, Marcus Wilhelm <mwil...@me.com> wrote:
First return false avoid loadingStop to be called, second setting href is async, means that the side still loads after your doThis function ends.
What you try is simply not possible, because the google code will override your javascript logic - you cannot handle the window.onload event anymore which would be the correct place to do loadingStop.


regards
Marcus
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com



Jon

unread,
Sep 7, 2010, 8:55:00 AM9/7/10
to phonegap
Half of my application is hosted locally, the other half remotely. The
remote half needs to be accessed from a hyperlink, so I disabled the
option for opening external links in Safari within Phonegap's config.
Now I just want something as simple as: the user clicks the link to
the remote website and while they wait for the remote website to be
contacted (if they're on a slow 2G connection for example), they are
made aware that the website is loading. At the moment, there is
nothing to inform them that their click has been accepted and the
remote web server is loading.

Surely this must be possible?


On 7 Sep, 12:55, Marcus Wilhelm <mwilh...@me.com> wrote:
> A javascript solution for this is not possible - since an external link will unload your javascript phonegap application. What do you want to do with external links?
>
> regards
> Marcus
>
> On 07.09.2010, at 13:08, Jon Winterburn wrote:
>
> > Not sure I fully understand you. So how do I achieve the desired result? I just want it so when the user clicks an external link, the loader informs them what is happening - a bit like this article:
>
> >http://nachbaur.com/blog/telling-your-user-that-a-phonegap-applicatio...

Marcus Wilhelm

unread,
Sep 7, 2010, 10:58:21 AM9/7/10
to phon...@googlegroups.com
you could call loadingStop in window.onload inside your external html files. You must understand that nothing of your javascript code is left, after the webview leaves a html file.

Marcus

RF

unread,
Sep 7, 2010, 11:22:50 AM9/7/10
to phonegap
If you want to stay inside you're application you'll have to implement
some sort of AJAX that will load your external links into a div rather
than navigating straight to the external link. You might also try
having the external links load in an iframe, that way you don't have
to go rewrite all of your external pages to implement AJAX

Jon

unread,
Sep 8, 2010, 5:59:27 AM9/8/10
to phonegap
I think you're right - I'll work on Ajax loader instead. Just a shame
as it would have been nice to utilise the functions phonegap provide
us with.
Reply all
Reply to author
Forward
0 new messages