Opening URL in a new htmlviewer

I have this code which is suppose to fetch a url in an htmlviewer on a window to another htmlviewer on another window which works as a popup browser, but it doesnt seem to work. it rather opens the popup browser as a blank page and it then opens the xojo file location on my computer. Can any one help me?

dim url As String
dim pop As new popupwindow
pop.Title = “Secured Guest Logging”
pop.Width = 500
pop.Height = 700
ShowURL(url)
Return pop.popupviewer

your URL variable doesn’t have a value
ShowURL forces the default web browser to load the URL
HTMLViewer.LoadURL is the command you want

Okay great, atleast that is a start, now how do i fetch the link of the clicked URL into the HTMLViewer.LoadURL()…?please help a newbie

You get the clicked URL in the CancelLoad event. In the URL property. If you return True, the HTMLViewer won’t go to that URL and you can open it elsewhere.

[code]Function CancelLoad(URL as String) As Boolean
dim pop As new popupwindow(URL)
pop.Title = “Secured Guest Logging”
pop.Width = 500
pop.Height = 700

Return TRUE
End Function[/code]

Thanks shao sean, but i get the error saying “This method requires fewer parameters than were passed”… The error is on
dim pop As new popupwindow(URL)

You would need to add a constructor method to popupwindow to accept the url and pass that on to it’s htmlviewer.

@Scott Siegrist how do i do that? could give me an example code?

@Michel Bujardet okay, i get it. But the problem i am facing now is that the CancelLoad event fires immediately my application opens. I want it to fire when an html link with _blank is clicked. so I will get its link and open it in a popup browser.

Michael,
when you click on a _blank link, the newWindow event should fire, allowing you to specify a different htmlViewer object to show it

hope this helps,

Giulio

@Giulio Mastrosanti … Thanks Guilio, I have this code in my NewWindow event which opens the new window as a popup, my problem i am having is how do i get the link clicked to appear in the htmlviewer in that new window. This is the code in the NewWindow event.

dim pop As  new popupwindow
  pop.Title = "Secured Guest Logging"
  pop.Width = 500
  pop.Height = 700
  pop.popupviewer.LoadURL()
  Return pop.popupviewer

i am so confused now, help me guys. pleaaaase. How do i get the clicked link into LoadURL, “popupviewer is the name of the htmlviewer”

you don’t have to loadUrl in the popviewer,

you must simply return popupviewer to let the app know where to open the new page

dim pop As new popupwindow
pop.Title = “Secured Guest Logging”
pop.Width = 500
pop.Height = 700
Return pop.popupviewer

should work, although if you declare ( dim) the window in the event itself, you will loose the reference to it

@Giulio Mastrosanti … Dont know what the problem is, but i just tried your method and it just loads an empty page displaying nothing. It seems it cannot get the url been clicked

I made a test and it works,
could you send me a sample project?

Okay @Giulio Mastrosanti how do i send you the test project?

put a link to download it, or send it to me at giulio@bitbazar.com

@Giulio Mastrosanti … I have sent the project to your email as requested. Thanks soo much for helping me out on this.