Page 2 of 2
Re: cancel browser widget navigation - possible?
Posted: Wed Oct 24, 2018 8:49 am
by [-hh]
You can set the contents as usual.
How do you script this update?
If using the htmltext then this works:
Code: Select all
on browserNavigateBegin pURL
set htmltext of me to myHTML()
end browserNavigateBegin
If using JS then this works:
Code: Select all
on browserNavigateBegin pURL
do myJS() in widget "browser"
end browserNavigateBegin
If using an URL then this works:
Code: Select all
on browserNavigateBegin pURL
set URL of me to myURL()
end browserNavigateBegin
Re: cancel browser widget navigation - possible?
Posted: Wed Oct 24, 2018 9:35 am
by rodneyt
This technically works, but forces my single page app to reload. This ejects user from their editing session (tabs/docs open in the web app)...
Any thoughts for a solution which doesn't result in my web app being reloaded?
[-hh] wrote: Wed Oct 24, 2018 8:49 am
If using an URL then this works:
Code: Select all
on browserNavigateBegin pURL
set URL of me to myURL()
end browserNavigateBegin
~ Rodney
Re: cancel browser widget navigation - possible?
Posted: Wed Oct 24, 2018 10:39 am
by [-hh]
Perhaps this is the simplest method before you add more new side conditions
1. Add a global to your JS:
Code: Select all
<head><script>var myGlobal=true;</script></head>
2. Add the following onclick handler to your links, for example:
Code: Select all
<a href='http://www.hyperhh.org' onclick='return myGlobal;'>Hi</a>
3. In LiveCode only add the following to your session start:
Code: Select all
do "myGlobal=false" in widget "browser"
Then your links don't work in LiveCode but in an ordinary browser.
For testing you could make a check button "Links Enabled", scripted with
Code: Select all
on mouseUp
do ("myGlobal="&the hilite of me) in widget "browser"
end mouseUp
[In case you have't seen how to navigate back/forward:
Code: Select all
go <back|forward> in widget "browser"
Of course this is only working if the widget has URLs available].
Re: cancel browser widget navigation - possible?
Posted: Wed Oct 24, 2018 2:07 pm
by AndyP
I still do not understand why this does not work for you?
The browser widget URL is set to 2108.co.uk in its properties pallet.
on browserNavigateBegin pUrl
if "2108.co.uk" is not among the words of pUrl then
exit to top
end if
end browserNavigateBegin
See the screenvid of it in my setup. Win 10 LC 8.14 Community, that shows it working.
http://2108.on-rev.com/nextcloud/index. ... 3HKH2qkmPq
Do you not see the same results? Links from the domain 2108.co.uk are actioned but outside links are ignored.
Re: cancel browser widget navigation - possible?
Posted: Wed Oct 24, 2018 10:52 pm
by rodneyt
Andy, my guess is that on MacOSX we're using a different browser (maybe Safari?) than on windows (which my guess, is using Chromium?). That could account for different behaviour.
AndyP wrote: Wed Oct 24, 2018 2:07 pm
I still do not understand why this does not work for you?
The browser widget URL is set to 2108.co.uk in its properties pallet.
on browserNavigateBegin pUrl
if "2108.co.uk" is not among the words of pUrl then
exit to top
end if
end browserNavigateBegin
See the screenvid of it in my setup. Win 10 LC 8.14 Community, that shows it working.
http://2108.on-rev.com/nextcloud/index. ... 3HKH2qkmPq
Do you not see the same results? Links from the domain 2108.co.uk are actioned but outside links are ignored.
Re: cancel browser widget navigation - possible?
Posted: Wed Oct 24, 2018 10:55 pm
by rodneyt
There's always:
on browserNavigateBegin pUrl
if not (pUrl contains "DOMAIN") then
do "window.stop();" in widget "X" of stack "Y"
exit to top
end if
Of course it's not really a solution as it stops all Javascript from running in the page....
But it does in fact also stop the page navigating away....
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 8:38 am
by AndyP
Andy, my guess is that on MacOSX we're using a different browser (maybe Safari?) than on windows (which my guess, is using Chromium?). That could account for different behaviour.
Maybe, then there should probably be a bug report raised as the browser widget is supposed to function in the same way across all platforms? I've just looked in the dictionary and can see no reference to differences on Windows or Mac.
Can another Mac and Windows user please test this.
The browser widget URL is set to 2108.co.uk in its properties pallet.
on browserNavigateBegin pUrl
if "2108.co.uk" is not among the words of pUrl then
exit to top
end if
end browserNavigateBegin
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 2:11 pm
by bogs
Heya Andy,
I tried, since I sort of have both environments to play with, but am not getting reliable results from the later IDEs.
Mac 10.6.5 Lc 8.1.8 (latest I can run there) -
test doesn't appear to work, but am not able to confirm that I am not screwing something up. Tested by setting up the stack the way you listed, slight modifications afterwards.
Code: Select all
// browser widget code ...
on browserNavigateBegin pUrl
if "2108.co.uk" is not among the words of pUrl then answer "Not a 2108 address"
browserNavigateBegin pUrl
// placed 2 buttons below browser widget, set the labels to [www.google.com] and [2108.co.uk]...
// code in card script...
on mouseUp
set the url of widget "Browser" to "https://" & the label of the target
end mouseUp
..1. no matter which button I clicked, the answer dialog showed up reporting that this is not a 2108 address.
![osxTest [Running] - Oracle VM VirtualBox_081.png (149.54 KiB) Viewed 9483 times Google...](./download/file.php?id=10239&t=1&sid=4c4d833baca3f182a1a56dbc4285cf1a)
- Google...
![osxTest [Running] - Oracle VM VirtualBox_080.png (186.79 KiB) Viewed 9483 times 2108....](./download/file.php?id=10238&t=1&sid=4c4d833baca3f182a1a56dbc4285cf1a)
- 2108....
I resolved this was changing the line "if "2108.co.uk" is not among the words of pUrl then answer "Not a 2108 address" to the following -
Code: Select all
if "2108.co.uk" is not among the characters of pUrl then answer "Not a 2108 address"
I don't have a windows box with a connection to the internet, so couldn't perform the test on one of those systems, but will setup one just to see.
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 2:32 pm
by bn
Hi Andy,
if "2108.co.uk" is not among the words of pUrl then
this does not work because "2108.co.uk" is 3 words. And you could only test one word with "is among the words".
but still even with
Code: Select all
if not (pURL contains "2108.co.uk") then
it does not work, i.e. is does not prevent going to e.g. Twitter from your page because Twitter" has "2108.co.uk in its URL as referrer.
After a little experimentation I can stop leaving the website using
Code: Select all
on browserNavigateBegin pUrl
--put pURL && the milliseconds & cr after msg
if not (pURL contains "http://2108.co.uk") then
set the htmlText of widget 1 to "<p>Patience, we will be back</p>"
set the url of widget 1 to "http://2108.co.uk"
end if
end browserNavigateBegin
tested using the Twitter link on your homepage.
I know almost nothing about the browser widget so I am of little help here.
Kind regards
Bernd
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 5:33 pm
by jacque
this does not work because "2108.co.uk" is 3 words.
Were you thinking of truewords?
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 5:47 pm
by bn
No, I probably did not think at all. Actually it did not work and I thought the punctuation mark was the end of a word. But it turned out that it did not work because there was like "
http://2108.co.uk/" and similar and that messed up "word" - boundaries.
And yes, "2108.co.uk" is one word as long as it is preceded and followed by space.
Thank you Jaque
Kind regards
Bernd
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 9:54 pm
by bogs
OOoooo, I like Bernd's spin better than mine, I couldn't figure out why the twitter link was going with the way I set it up. Good explanation Bn!
Re: cancel browser widget navigation - possible?
Posted: Thu Oct 25, 2018 10:24 pm
by jacque
bn wrote: Thu Oct 25, 2018 5:47 pm
No, I probably did not think at all.
LOL. I often have the same problem.

It gets worse with age.