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.