Launch url in browser widget

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Launch url in browser widget

Post by SEAL29 » Mon Oct 12, 2020 4:19 pm

I tried this code, but not working, does not load the page.

Code: Select all

on mouseUp
   ## Note the number of cards of your stack
   ask "Go to url:"
   put it into tURL
   
   ## Check if user clicked CANCEL...
   if the result = "cancel" then
      # ... get out of here!
      exit to top
   end if
   
   if tURL is url then
      ## Finally! :-)
      launch url tURL in widget "web"
   end if
end mouseUp

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Launch url in widget field

Post by dunbarx » Mon Oct 12, 2020 4:52 pm

Hi.

This line:

Code: Select all

if tURL is url then
references a variable ("url") that I do not see anywhere. What did you intend by this? In other words, what did you think was in url, that the result of the original user entry was going to match?

Anyway, your handler will never pass that conditional, because tURL is never going to equal url.

Step through the handler. Do you know how to do this? At each line you will see the contents of all variables. Note that "url" though listed, is empty.

Craig
Last edited by dunbarx on Mon Oct 12, 2020 4:55 pm, edited 1 time in total.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Launch url in widget field

Post by Klaus » Mon Oct 12, 2020 4:54 pm

Hi SEAL29,

Code: Select all

...
#  if tURL is url then
# Does not work, we cannot directly check if a string is a valid URL!
# You could check if tURL begins with HTTP or WWW or something

# launch url tURL in widget "web"
# Not the correct syntax for the browser widget!
# ALWAYS check the dictionary if in doubt!

# This is the right way:
  set the URL of widget "web" to tURL
end mouseUp
Best

Klaus

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Launch url in widget field

Post by SEAL29 » Mon Oct 12, 2020 5:02 pm

Klaus wrote:
Mon Oct 12, 2020 4:54 pm
Hi SEAL29,

Code: Select all

...
#  if tURL is url then
# Does not work, we cannot directly check if a string is a valid URL!
# You could check if tURL begins with HTTP or WWW or something

# launch url tURL in widget "web"
# Not the correct syntax for the browser widget!
# ALWAYS check the dictionary if in doubt!

# This is the right way:
  set the URL of widget "web" to tURL
end mouseUp
Best

Klaus
Thank you. :D

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Launch url in widget field

Post by Klaus » Mon Oct 12, 2020 5:16 pm

Please get used to the LC terminology, your "Subjects" are always a bit irritating! :)

A button is a button.
A field is a (text) field.
An image is an image and no field.
A widget can be anything, here it is a "browser widget", but there is no "widget field".

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Launch url in widget field

Post by dunbarx » Mon Oct 12, 2020 6:33 pm

Klaus is not really irritated. But he does make a point.

Oftentimes we are misled by either the subject itself or early descriptions of the issue, if they include the wrong terms. It is common for new users to use such words as "field", when they really just mean "some solid concept that I need talk about".

You will soon learn what to call things, or not to name anything at all. Keep practicing with LC.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Launch url in browser widget

Post by FourthWorld » Mon Oct 12, 2020 7:08 pm

It's simple for a moderator to modify the opening post title. So I did.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Launch url in browser widget

Post by SEAL29 » Mon Oct 12, 2020 7:16 pm

Thanks for the information.

Post Reply