# Web browser component class

**URL:** <https://forum.juce.com/t/web-browser-component-class/2840>\
**Category:** General JUCE discussion\
**Created:** [May 16, 2008, 3:35pm UTC](https://forum.juce.com/t/web-browser-component-class/2840 "2008-05-16T15:35:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 16, 2008, 3:35pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/1 "2008-05-16T15:35:34Z")

</div>

Hello folks

For those of you using the tip, I’ve just checked-in a new class WebBrowserComponent, which lets you easily embed a simple IE or Safari browser in your UI. If this is useful to anyone, I’d appreciate you having a go and letting me know if it works ok!

---

<div class="post-metadata">

**Author:** ![ptomaine](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ptomaine/32/245_2.png) [@ptomaine](https://forum.juce.com/u/ptomaine)\
**Post date:** [May 16, 2008, 3:56pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/2 "2008-05-16T15:56:04Z")

</div>

Great! Thanks!

---

<div class="post-metadata">

**Author:** ![ring2](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@ring2](https://forum.juce.com/u/ring2)\
**Post date:** [May 16, 2008, 6:39pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/3 "2008-05-16T18:39:32Z")

</div>

what a cool!!!

I have just made a simple web browser in 5 minutes using Xcode and Jucer!! Creating a new project using template, put a textEditor for URL, put a generic component and set it as WebBrowserComponent, then write some code on Xcode! That’s all!

Although I see there are some issues, but it’s really nice!!

- getCurrentUrl()?
- getProgress()?
- I wish there will be a kind of class like WebBrowserComponentListener which tells various event like UrlChanged(), UrlRequestTimedOut()…

Sorry for a lot of things, I know it’s just a first step though. I think you’ve already planned those. 😃

Cheers,  
Masanao Hayashi

---

<div class="post-metadata">

**Author:** ![ptomaine](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ptomaine/32/245_2.png) [@ptomaine](https://forum.juce.com/u/ptomaine)\
**Post date:** [May 16, 2008, 9:33pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/4 "2008-05-16T21:33:11Z")

</div>

Well, MinGW does not compile the WebBrowserComponent component smoothly. In order to change that you have to move #include \<comutil.h\> line into the #ifdef \_MSC\_VER block because it’s VS specific. Then you have to replace \_variant\_t type to VARIANT. After that the component are compiled fine.

Another issue is that when the browser component is a child of a TabComponent component then my test application crashes on switching between tabs (activate browser tab -\> switch to another tab -\> CRASH!).

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [May 17, 2008, 7:30am UTC](https://forum.juce.com/t/web-browser-component-class/2840/5 "2008-05-17T07:30:48Z")

</div>

Just upgraded to the SVN tip to try this (I’ve been using rev 422 for a while). I can’t get to work straight away on Mac (10.4.11, XCode 2.5) though I had to modify the XCode project to reference the .mm files rather than .cpp files (for the Mac specific code for the audio burner & network). I thought I’d just try it in the example project and replace the HelloWorld component with the web browser. But again there were some extra files referenced in the example project XCode project I had to remove so I’m not sure if there are other files awry.

Anyway I get these warnings when compiling the Juce libs (with the 10.4 or later settings):

`	/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:128: warning: no '-setPolicyDelegate:' method found	/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:128: warning: (Messages without a matching method signature	/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:136: warning: no '-setPolicyDelegate:' method found	/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:219: warning: no '-goBack' method found	/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:224: warning: no '-goForward' method found
/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:273: warning: no '-mainFrame' method found	/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:274: warning: no '-mainFrame' method found
/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:274: warning: no '-loadRequest:' method found `

I presume I need to add WebKit.framework to the project when building the application but I still get these undefined symbols:

```auto
.objc_class_name_NSData
.objc_class_name_NSMutableURLRequest
.objc_class_name_NSObject
.objc_class_name_NSString
.objc_class_name_NSURL
```

---

<div class="post-metadata">

**Author:** ![mdsp](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mdsp](https://forum.juce.com/u/mdsp)\
**Post date:** [May 17, 2008, 7:58am UTC](https://forum.juce.com/t/web-browser-component-class/2840/6 "2008-05-17T07:58:02Z")

</div>

you need the Cocoa.framework too

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [May 17, 2008, 11:41am UTC](https://forum.juce.com/t/web-browser-component-class/2840/7 "2008-05-17T11:41:57Z")

</div>

> [@mdsp](#):
>
> you need the Cocoa.framework too

Thanks, all working now - very cool. So the compiler warnings for the Juce libs are presumably as harmless as the deprecated QuickDraw call warnings?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 19, 2008, 11:59am UTC](https://forum.juce.com/t/web-browser-component-class/2840/8 "2008-05-19T11:59:15Z")

</div>

Those warnings are really annoying - the code is absolutely fine, but because of the stupid dynamic-binding in obj-C, it throws out warnings when it can’t prove that a method call is valid. There might be a way to write it to avoid them, but I’m only an obj-C noob.

---

<div class="post-metadata">

**Author:** ![auspuff](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@auspuff](https://forum.juce.com/u/auspuff)\
**Post date:** [May 19, 2008, 12:02pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/9 "2008-05-19T12:02:23Z")

</div>

Have you tried it on 10.5? It compiles and runs fine after adding the webkit and cocoa frameworks but I can’t get it to actually show a webpage. All I see is a black component.

goToURL() does not seem to do anything.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 19, 2008, 12:22pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/10 "2008-05-19T12:22:07Z")

</div>

Yep, I use 10.5 all the time…

---

<div class="post-metadata">

**Author:** ![jaydee](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jaydee](https://forum.juce.com/u/jaydee)\
**Post date:** [May 19, 2008, 12:53pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/11 "2008-05-19T12:53:16Z")

</div>

Include

```auto
#import <WebKit/WebKit.h> at the top of juce_mac_WebBrowserComponent.mm
```

That’ll get rid of the compile warnings as now its aware of the Obj C functions

Also the method for stop() in WebBrowserComponentInternal should be

```auto
 void stop()
{
        [webView stopLoading:nil];
}
```

Apple also suggests Carbon apps call NSApplicationLoad() as soon as they can, probably in the Juce GUI Initialize.

Justin

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 19, 2008, 1:38pm UTC](https://forum.juce.com/t/web-browser-component-class/2840/12 "2008-05-19T13:38:34Z")

</div>

Ah! someone with proper obj-C skillz! Personally, I can’t stand the language!
