Real Software Forums
http://forums.realsoftware.com/

HTMLViewer link handling
http://forums.realsoftware.com/viewtopic.php?f=21&t=45087
Page 1 of 1

Author:  shaosean [ Wed Aug 22, 2012 8:54 pm ]
Post subject:  HTMLViewer link handling

I am using a HTMLViewer with LoadPage and passing in an imported HTML page
me.LoadPage default, Nil


Now, I want any links in the HTML to be clickable, so I follow Christian's advice from his posting to the mailing list, but make some modifications as I am not loading a webpage hosted on a server
Function CancelLoad(URL as String) As Boolean
// http://support.realsoftware.com/listarchives/realbasic-nug/2010-02/msg00873.html - Christian Schmitz

const kEventHandled = TRUE
const kEventNotHandled = FALSE

if (url = "about:blank") OR (url.Left(4) = "file") OR (url.Left(2) = "C:") then // about:blank is for Mac OS X WebKit, file is for Win32 WebKit and C: is for Win32 native
Return kEventNotHandled
else
ShowURL(url)
Return kEventHandled
end if
End Function


The first "if" line will make sure our page loads on the different OSes and with the different web browsers (sorry Linux users, I cannot seem to get the HTMLViewer to work in on my install)..

The URL parameter will contain one of the following:
"about:blank" on Mac OS X webkit
an absolute file path to the temp file, starting with "file:///" on Win32 webkit
an absolute file path to the temp file, starting with "C:\" on Win32 native renderer

Remember, this is only when you are passing in HTML source to the LoadPage.. Hopefully that makes sense and helps someone out :-)
-Sean

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/