WebBrowser problem


#1

Hi Jules,

I’m trying to use the WebBrowser on Mac to show simple html help files, but I can’t get anything to show. The URL given (and I’ve checked that it is correct) is the full path to the html file prepended with “file://”. This is on Mac OS X 10.6.7.

Ideas ?

TIA,
/Rob


#2

That’s kind of strange. Have you tried typing the URL into the web browser page in the demo app?


#3

I only get “Enter a web address, e.g…”. The URL I use is:
file://

I can see the page in Firefox with the same URL.


#4

This might have something to do with the WebView not showing the file URL:http://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html#//apple_ref/doc/uid/20001903-DontLinkElementID_1


#5

Does the URL have special characters like space, & etc?


#6

It does have spaces yes… like:
"/Applications/My App.app/Contents/Resources/html/my_html_page.html"

DOH! Thanks. Me and web stuff… URL escaping fixed it. Thanks mate!


#7

Safari is more strict on url format compared to other browsers. It is a good practice to add escape characters to all the urls.


#8

Yeah, does seem so. However now I’m riddled with another problem: When I run in Xcode, the WebBrowserComponent always brings up the bundled help files, but when I’ve deployed the application, sometimes it doesn’t. And sometime it does. Anyone seen anything like this ?

Edit: When it doesn’t work, I use Finder to “Show Package Contents”. Then I open the application again, and then it works! This is NUTS!


#9

Wow. That’s a doozy of a problem!

Bear in mind that Apple do some dodgy stuff inside their modules. I once spent 2 days wondering why I couldn’t get Quicktime to work inside a browser plugin before I figured out that Apple had deliberately crippled it to prevent it working in Firefox…


#10

Try logging the url given to the webbrowsercomponent. It could be the case that the path is going wrong.


#11

Thanks guys, although what is looks like is that the WebView object simply doesn’t exist at the times when it doesn’t work. I.e. right-clicking in the component doesn’t yield the “Reload” popup menu. What could possibly make it not instigate the WebView ?


#12

The only time I faced a similar issue with webbrowsercomponent was, when I added webbrowsercomponent to a view before that view was visible.


#13

Thanks! Indeed. The url given to the component was within the initialization code, so sometimes it mustered it, sometimes not. Now I postpone that via a message, along with the instantiation of the webbrowsercomponent, and that seems to work! :slight_smile:


#14

Perhaps if you ask it to go to a URL before it’s had time to get its internal threads ready, it just ignores the request.


#15

Maybe, but it seems more than that. Subsequent url request fail too, and the WebView seems totally uninitialized.


#16

It is an issue with initialization of the webbrowsercomponent. Similar behaviour is seen on windows too.


#17

Strange. I have the same exact code for both platforms, but is is only Mac I’ve seen this on…


#18

In that case it is very strange. I had seen this on Windows and Macintosh more than a year back. It looked like ActiveXComponent wasn’t getting initialized if the parent view was not visible and on Mac it looked like an issue with WebView failing to initialize.