Open Browser Link in Safari instead of Browser

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Open Browser Link in Safari instead of Browser

Post by Tester2 » Mon Dec 12, 2011 10:56 pm

I have an html List View page on my server with a list of links and I am displaying it in my app via the in-app Browser.

Whenever someone clicks on the links on my html page, I would like the user to be taken to that link in Safari not in my in-app Browser.

How do I do this??

Please help! :(

Thanks bunches.

-Tester2

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open Browser Link in Safari instead of Browser

Post by Jellicle » Mon Dec 12, 2011 11:22 pm

(From the release notes)

URL launching support

Support for launching URLs has been added. The launch url command can now be used to request the opening of a given url:

launch url urlToOpen

When such a command is executed, the engine first checks to see if an application is available to handle the URL. If no such application exists, the command returns "no association" in the result. If an application is available, the engine requests that it launches with the given url.

Using this syntax it is possible to do things such as:

• open Safari with a given http: url
• open the dialer with a given phone number using a tel: url

Important: Successfully launching a url will cause another application to open and the requesting application to be quit. The application will receive a shutdown message before this happens, however.
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Re: Open Browser Link in Safari instead of Browser

Post by Tester2 » Tue Dec 13, 2011 12:36 am

This is probably a dumb question, but bare with me as I'm a beginner. :lol:

I have the following code on a button:

on mouseUp
go to card "1"
put "http://000.00.000.000/Folder/list_view_links.html" into field "Web"
end mouseUp

Then on the card 1, I am creating a Browser and setting the URL to the "Web" field.

How would I incorporate the launch url urlToOpen? The links that I want to open in Safari are listed in my html page's code not in the app...

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open Browser Link in Safari instead of Browser

Post by Jellicle » Tue Dec 13, 2011 10:26 am

I think you can use a browserLoadRequest handler to catch requests to load URLs, and to handle them in alternative ways.

So something like (in a card script):

on browserLoadRequest pUrl
launch url pUrl
end on browserLoadRequest

pUrl is a parameter sent by the browser control - it'll contain the url selected by the user.

I can't try that out at the moment, so if it doesn't work...sorry :)

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Re: Open Browser Link in Safari instead of Browser

Post by Tester2 » Wed Dec 14, 2011 7:51 pm

Hey Gerry,

Thanks so much for the reply.

I tried what you said and messed around with it and figured it out.

Since my delayRequests was not set to true I had to use

on browserLoadRequested pUrl, pType
launch URL pURL
end browserLoadRequested

instead of "browserLoadRequest"

But then it worked lovely. ;)

Thanks again...

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open Browser Link in Safari instead of Browser

Post by Jellicle » Wed Dec 14, 2011 10:31 pm

Tester2 wrote:But then it worked lovely. ;)
Excellent :)

g
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Post Reply