How do i get the exact url of something clicked on in htmlviewer.
Why do you start a new topic ? It would make more sense in https://forum.xojo.com/23731-opening-url-in-a-new-htmlviewer where already a lot of people tried to help you.
He did not made the thread
What do you mean ? In both threads, he is the OP…
I missclicked. You are correct. I am sorry for this.
Its alright. My main concern is that when topic are splintered that way, it makes finding the information more difficult.
Maybe i didnot put my question right, @Michel Bujardet , yes I have opened a similar thread but this is another problem I am facing, I am completely new to xojo and this platform so please forgive my ignorance. I just want to be able to fetch a URL when clicked in a textbox, let me explain myself well. Lets say a user clicks on a link in the htmlviewer ie . “http://www.google.com/something.pdf” . I want to be able to open a new browser window, which i can do, and fetch the URL clicked into a textbox in the new Window. My problem is fetching the URL clicked. How do i go about that?
copying and pasting by the other thread
the DocumentBegin event of the HTMLviewer gives you the URL about to load.
You do it in CancelLoad.
In the other thread I already told you, and shao Sean tried to give you some example code.
What you need to do is to
- Add to your project a new window with an HTMLViewer on it that you will use to display the new browser window. Let use call it BrowserWindow, and the HTMLViewer inside HTMLViewer1.
In your main window,
-
Add the cancelload event to your HTMLViewer
-
In CancelLoad, verify that it is not the same as the URL you have used in LoadURL to initiate your browsing session, which you have saved in a window string property called myURL. If it is different, display a new browser window.
Here is the minimal code in CancelLoad
If URL <> myURL then
dim newbrowser as new BrowserWindow
newbrowser.HTMLViewer1.LoadURL(URL)
Return True
end if
I forgot the show if the window is not implicit :
If URL <> myURL then
dim newbrowser as new BrowserWindow
newbrowser.show
newbrowser.HTMLViewer1.LoadURL(URL)
Return True
end if