XAML WebBrowser emulation without registry change - wpf

I am trying to render some HTML page of mine hosted on a NodeJS in a WPF app.
I have tried few things and the following option seems the most convenient:
C# webbrowser Ajax call
However it is modifying the registry which I cannot (company policy).
Therefore would there be a way to do the same on the fly? ie. load the WebBrowser with this setup without updating the registry?
Thank you

You might be able to do this with the XUA compatible meta tag.
<meta http-equiv="x-ua-compatible" content="IE=11">
I don't know if you have access to the site's content or not. If you do, then just put in right there in the HTML.
If you do not own the page, there are ways modify the page and dynamically inject this tag with a bit of com interop from mshtml.

Therefore would there be a way to do the same on the fly? ie. load the WebBrowser with this setup without updating the registry?
I am afraid not. There is no property or method of the WebBrowser control itself that you can set or call.
Changing the registry keys or use another (third-party) control are your only options I would say.

Related

WP7 WebBrowserTask without url entry textbox

This might not be possible but I thought I'd check with everyone.
Is it possible to load a WebBrowserTask on WP7 but to have the url entry box collapsed? I'd also like to set IsHitVisble to false?
The reason I want to do this is to load a url (through databinding) but ensure that the user can't browse to other links on the page. I also need to keep the phones share control in the tool bar so I can't just use a webbrowser control and set the source to the url.
Does anyone have any ideas?
Not possible. You can use a WebBrowserControl inside your own app, but it's not recommended.
Basically such odd/weird limitations as this, don't belong in any modern day craftsmanship. And thus why it isn't a possibility (thanks Microsoft!)

Showing the result of a WebClient-postback in an Browser Window from Silverlight 4

I want to show the result of a WebClient-Postback in an new Browser-Popup-Window. As the "Navigate" and "Popup" methods of HtmlPage only support Get-requests, I issued an POST-request to an REST-Service via WebClient. But now I want to show the result (e.g. application/ms-excel or application/pdf) in an new Browser-Window.
Therefore, can I open an new BrowserWindow and set its contents as well as some corresponding http-headers with on-board means of Silverlight 4? Or even better, is an easier way to trigger the browser to do the POST-request to the service?
Best Regards
I tried going this route but the WebBrowser control is not opened to the developer. What I did as a temporary workaround was to open my webpage http://www.xyz.com/default.aspx inside the WebControl and let the page drive the rest.
Mike Taulty had an example for somthing like this, how you can use javascript to communicate back to the silverlight app through InvokeScript:
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-html-hosting-in-the-webbrowser-control.aspx
I hope it helps!

MSIEs WebBrowser control hosted in winforms app runs in compatibility mode

I'm hosting MSIE in a winforms form. Unfortunately it insists on running in compatibility mode regardless of if I give it a page that runs in IE8 mode in stand-alone IE. The effect of that is that some content that renders correctly in stand-alone MSIE gets completely mis-aligned and messed up in the hosted control.
Besides document type etc, is there some magic way to tell the webbrowser that I want it to render the page the same way as if I loaded it in stand-alone MSIE?
I don't want to use the registry key override ( http://blogs.msdn.com/b/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx ) due to my form being part of an add-in for another app. I don't want to change the IE behavior for the main app and I don't want to change it for other add-ins running under that app. I only want this to work within the browser hosted in my form, not app-wide and not process-wide.
I have not tested this, but how about using the META tag, along with the HTTP-EQUIV attribute, to set the X-UA-COMPATIBLE value to IE=8, which instructs the web browser to display a page in IE 8 standards mode. An example would be:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
From this line in the following article it seems that this should work.
By default, applications hosting the
WebBrowser Control open
standards-based pages in IE7 mode
unless the page contains an
appropriate X-UA-Compatible header.
You can change this by adding the name
of the application executable file to
the FEATURE_BROWSER_EMULATION feature
control key and setting the value
accordingly.
To change the default behavior of the Web Browser Control running in your application to match what IE itself does, you must set the FEATURE_BROWSER_EMULATION Feature Control Key.
For instance, you can mimic IE8's behavior (allowing sites to render in IE8 standards mode) as follows.
Inside HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl
Create a new key named FEATURE_BROWSER_EMULATION
Inside that key, add a new REG_DWORD with value 8000 with the name of your application's executable. E.g.:
"YourApp.exe" = dword 8000 (Hex: 0x1F40)
Further details are at:
http://blogs.msdn.com/b/ie/archive/2009/03/10/more-ie8-extensibility-improvements.aspx

WPF WebBrowser NavigateToStream & images

I'm planning to use thw WebBrowser component to display html that is created on the fly. The perfect choice for this is NavigateToString or NavigateToStream methods. There's only one single problem - I need to load images / css styles / js files too. How do I accomplish this while using string/stream?
As an option I'm also considering writing/finding simple http server and running it on some port, but that's an additional work and requirements(open ports) so I'd like to avoid that if it's possible.
You can cast WebBrowser.Document to IPersistMoniker and load a moniker that implements GetDisplayName. Check http://csexwb2.googlecode.com/svn/trunk/cEXWB.cs for example code.
Faced with this same problem I created my own solution. You can see it here:
Reference an image imbedded in a WPF application from within an HTML file used as help content

Is there a "Browser Control" to host a website inside Flash/Silverlight?

I'm looking for something similar to the VB6 / .Net Winforms "Browser Control", that let's you show a browser inside your application.
I don't want to just render a page, I want it to be a fully-functional browser, in which people can click links, will run Javascript, etc.
In essence, what I want is an IFrame, only that it runs inside a Flash app, or a Silverlight app.
The ultimate reason for this is that I want to defeat IFrame busters. I'm making a web app that lets you see other sites inside of it, and I'm running into a bunch of sites that have this code:
var t=top.location,w=window.location;if(t!=w) t.replace(w);
(that's from eBay BTW)
which essentially pops the user out of my site and into theirs.
My hope is that by using a "browser control" of some sort, inside a plugin sandbox, "top", will be top for that browser control, and not for my site.
Of course, if you have any other ideas to achieve the same, they'll be more than welcome.
Edit: I've tried the Component One control suggested by Bill, but it didn't work for these purposes, because it's creating an IFrame outside of the SilverLight control, so it executes in the same context as the page hosting Silverlight, which is what I'm trying to avoid.
Northcode SWF Studio allows you to add browser window on the stage in Flash. I personally use SWF Studio as a third party SWF2EXE tool to extend the power of Flash projectors. It's quite stable and powerful. As far as browser control is concerned here is the example you can download and test if it serves your purpose. Check the Browser APT here.
We've not built a component to enable folks to do this but we're open to suggestions here. That being said, easiest solution is an iFrame, but word of caution in that when you overlay an iFrame over the the top of Silverlight we've seen customers experience perf issues as a result (mostly due to alpha transparency of the iframe etc).
This isn't isolated to Silverlight, Flash suffers the same issue as it has to do with browsers and rendering within the given operating system.
HTH.
Scott Barnes / Rich Platforms Product Manager / Microsoft.
I use the HTML control created by Component One. It has the limitation that the Silverlight object in the page should be set to windowless, but otherwise it works very well.
It's an old post but I'll add my tupence answer. I used the DivElements free control for Silverlight link text and it works quite nicely. It just positions the div accurately so that it looks like it's on top.
As for the other such controls, you've got to set the windowless property of the Silverlight container to true.
It works really well for me and I'm able to seemlessly have Google maps and the Acrobat plugin displayed side by side with my Silverlight application.
PS: because the component just adds a <div> to the page, you can't do stuff like having it load dynamically Javascript file like in the <header> tag.
PPS: when setting the HTML code "by hand", be sure to hook up on the DocumentReady or Loaded event before playing with the HTML DOM.
Hope that helps someone.

Resources