Page 1 of 1
Launch url in browser widget
Posted: Mon Oct 12, 2020 4:19 pm
by SEAL29
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
Re: Launch url in widget field
Posted: Mon Oct 12, 2020 4:52 pm
by dunbarx
Hi.
This line:
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
Re: Launch url in widget field
Posted: Mon Oct 12, 2020 4:54 pm
by Klaus
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
Re: Launch url in widget field
Posted: Mon Oct 12, 2020 5:02 pm
by SEAL29
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.

Re: Launch url in widget field
Posted: Mon Oct 12, 2020 5:16 pm
by Klaus
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".
Re: Launch url in widget field
Posted: Mon Oct 12, 2020 6:33 pm
by dunbarx
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
Re: Launch url in browser widget
Posted: Mon Oct 12, 2020 7:08 pm
by FourthWorld
It's simple for a moderator to modify the opening post title. So I did.
Re: Launch url in browser widget
Posted: Mon Oct 12, 2020 7:16 pm
by SEAL29
Thanks for the information.