Page 1 of 1

How do I get the current URL of the page loaded in the browser widget

Posted: Sat Nov 08, 2025 8:22 am
by jameshale
Hi all,

I am stumped at determining the URL of the current page being displayed in the browser widget.

I have a stack with the widget and I set its URL

The page displays and I can interact with it.
Great.

I then click on a link within the page (actually on a pop upwundow) and go to another page.

How do I get the URL of this page?

Looking at the dictionary it seems I could respond to "browserDocumentLoadComplete pUrl"

But I don't know how to use it.
I am assuming it can be located in a script in the card.
So I tried...

Code: Select all

on browserDocumentLoadComplete pUrl
   put purl
end browserDocumentLoadComplete
But nothing.

Any ideas?

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Sat Nov 08, 2025 10:24 am
by Klaus
Hi James,

this works for me:

Code: Select all

on browserDocumentLoadBegin tUrl
   put tUrl
end browserDocumentLoadBegin
However "browserDocumentLoadComplete" also worked for me, but only tested in the IDE.

Best

Klaus

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Sat Nov 08, 2025 1:02 pm
by jameshale
Hi Klaus,
No still nothing here.
Was your script in the card?

James

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Sat Nov 08, 2025 1:07 pm
by Klaus
Yes, script was in the card.

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Sun Nov 09, 2025 6:12 am
by jameshale
Seems like it is the site I am going to. I need to invesitage more.

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Tue Nov 11, 2025 9:22 pm
by bobcole
This intrigued me so I did some research.
It looks like there is a direct way of getting the URL of the browser.

Code: Select all

on getTheURL
   get the URL of widget "MyBrowser"
   put it & return after field "The URL"
end getTheURL   
I hope this works for you.
Bob Cole

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Tue Nov 11, 2025 11:54 pm
by jameshale
Thanks Bob for the thought.
Interestingly using your handler only returned "false"!!!
Removing the "and return" gave me a URL.
Unfortunatley this URL did not change when I changed pages in the widget.
Bizarrely nothing I did changed it. It was correct for the site, as tested in an actual browser but I couldn't get it to change for the widget no matter what I did on the page.
I also tried handlers using all of the messages associated with the widget.
none of them triggered when I clicked on links in the widget.
Yet the page displayed did.

In doing the same in Safari, the url of the page does change with every click.
So I am flummoxed as to why the widget fails to pick this change up even though it changes what it displays.

BTW on other sites things seem fine, it must be something to do with the way this particular site/page is constructed.

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Thu Nov 13, 2025 12:02 am
by bobcole
This works on my system. take a look.
If it doesn't work for you that means something else is the problem.
I am using a Mac M1 laptop, lots of RAM and disk space.
What system are you using?
Bob
Browser Widget.livecode.zip
(1.51 KiB) Downloaded 41 times

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Thu Nov 13, 2025 12:31 am
by jameshale
Hi Bob,
needed to enter the URL in the widget's property inspector for it to register (go figure?)
However on the site I am interested in no change in the reported URL.
I looked at the script and noticed you are expecting a "browserDocumentLoadComplete" message (as did I), however the site I am on doesn't trigger it.
Each page has a next/prev arrow which does change pages but the widget although displaying the new page sends no message. As I mentioned before it I works fine using an actual browser. Changing pages is reflected in the URL show in the browsers address bar.
Something weird in my site of interest or broken in the widget.
BTW the site I am looking at is <https://acim.org/acim/en>

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Thu Nov 13, 2025 8:01 pm
by SparkOut
Sounds like the site of interest is dynamically creating/changing content. This is happening all over the internet, making it tricky to use a static interface within LC to manage/manipulate the content.
Hermann (sadly no longer with us) here has some amazing stacks that leverage javascript within LC browsers to do some incredible interactions. I'm not sure what contributions of his still remain, and how any ofvthdm might be generalised to your requirements. Otherwise the only thing possible is to investigate the specific site and work out what controls are happening and maybe devise a way of making the dynamic responses.
I don't mind volunteering to take a look and seeing if I can work anything out, but make no promises as to timeframe nor claims as to chances of success.

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Thu Nov 13, 2025 8:40 pm
by dunbarx
I miss Hermann. But all his posts are still here.

Craig

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Thu Nov 13, 2025 9:17 pm
by SparkOut
dunbarx wrote:
Thu Nov 13, 2025 8:40 pm
But all his posts are still here.
Unfortunately there is a huge amount redacted from here and as much or more missing from his hosted collections / no longer hosted :(
A great loss, personally and productively.
The saddest is the personal loss. I remember a few private conversations. A fine gentleman.

Re: How do I get the current URL of the page loaded in the browser widget

Posted: Fri Nov 14, 2025 4:22 am
by bobcole
I spent some time with your website of interest: https://acim.org/acim/en
I don't have an answer as to why that website doesn't send the browserDocumentLoadBegin/Complete messages.
I have some observations, however.
1 - The web pages addresses can be seen by clicking on Terms of Service then return to the website. I used the Terms of Service page as an example, other pages may do the same thing. Note the address at the bottom after the Return button is clicked. The web address shows at the bottom of the screen.
2 - Did you know that the web pages are directly addressable? I put several of them into my Browser Widget app (see attached).

I don't know why this does not work when the page forward / page backward buttons are pressed.
Maybe someone else can figure this out.
Bob
Browser Widget 2.livecode.zip
(1.83 KiB) Downloaded 33 times