I have code (and for decades) that:
given some HTML string in memory
hand that document to an Internet Explorer object
and make Internet Explorer (separate process) visible
all without littering the user's computer with temporary files
In other words:
void SpawnIEWithSource(string szSourceHTML)
{
IWebBrowser ie = (IWebBrowser)CoCreateInstance(CLASS_InternetExplorer, null, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
UuidOf(IUnknown));
ie.Navigate2("about:blank");
ie.Document.Write(szSourceHtml);
ie.Document.Close;
ie.Visible = True;
}
Pros:
opens an HTML report out of process
does not create a temporary file
Cons:
hard-codes the use of Internet Explorer, rather than the user's preferred browser
But IE is going away
Microsoft recently announced that Internet Explorer (the product) will no longer come with Windows, but Internet Explorer (the programming api) will continue to work:
As announced today, Microsoft Edge with IE mode is officially replacing the Internet Explorer 11 desktop application on Windows 10. As a result, the Internet Explorer 11 desktop application will go out of support and be retired on June 15, 2022 for certain versions of Windows 10.
Out of scope at the time of this announcement (unaffected):
Internet Explorer mode in Microsoft Edge
Internet Explorer platform (MSHTML/Trident), including WebOC
Internet Explorer 11 desktop application on:
Windows 8.1
Windows 7 Extended Security Updates (ESU)
Windows 10 Server SAC (all versions)
Windows 10 IoT Long-Term Servicing Channel (LTSC) (all versions)
Windows 10 Server LTSC (all versions)
Windows 10 client LTSC (all versions)
What is the MSHTML (Trident) engine? How does that relate to IE mode?
The MSHTML (Trident) engine is the underlying platform for Internet Explorer 11. This is the same engine used by IE mode and it will continue to be supported (in other words, unaffected by this announcement). WebOC will also continue to be supported. If you have a custom or third-party app that relies on the MSHTML platform, you can expect it to continue to work.
(emphasis mine)
Which means that Microsoft is breaking 23 years of backwards compatibility - and replacing it with...nothing.
So i need to find a way to replace it.
spawn the default browser
give it HTML i want to display
all without temporary files
Bonus Reading
.NET: How to make WebBrowser control launch in IE, display HTML, out of process?
How to put the WebBrowser control into IE9 into standards?
How to start browser with html string with lua
Creating an IWebBrowser2 control
I'd encode HTML into Base64 and make it a Data-URI. All modern browsers are able to handle such URIs. This however won't work if your HTML string is too big.
Basically, it'd go like this:
string Base64Encode(string plainText) {
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
void SpawnBrowserWithSource(string szSourceHTML) {
System.Diagnostics.Process.Start("data:text/html;base64," + Base64Encode(szSourceHTML));
}
Resulting in:
(code snippets are from the following Stackoverflow answers: base64 encoding and opening default browser)
If you know the user uses Chrome or Edge, you can replace the WebBrowser instance with ChromiumWebBrowser, and use the LoadHtml method to inject the content.
Relevant links:
web browser control in winform with google chrome c#
https://www.telerik.com/support/kb/winforms/details/how-to-embed-chrome-browser-in-a-winforms-application
https://cefsharp.github.io/api/51.0.0/html/T_CefSharp_WinForms_ChromiumWebBrowser.htm
Related
Running StageWebView on a Windows Desktop machine, uses IE as it's browser, no matter what is the systems default Internet Browser. Is it possible to change this to Chrome?
I'm not interested in the built in Webkit browser in AIR
Sorry but the answer is no, the StageWebView class on mobile or desktop uses the OS provided web control to display content on the Stage:
On desktop computers (in the desktop and extended desktop profiles),
the StageWebView class uses the system web control provided by the
Flash Player plugin.
Thus on Windows that would be Internet Explorer (IE) via the IWebBrowser2 interface which Google's Chrome does not support.
Note: This is assuming you are passing true for the useNative parameter on the StageWebView constructor, otherwise the on Windows/OS-X you would get the old built-in Webkit version. This can be checked by seeing which user-agent is used (try http://whatsmyuseragent.com or similar to verify)
Air 18 (or 19 beta results in same rendering) on Windows and OS-X:
I'm creating a Audio Player with HTML5, using the MediaSource Object.
My code is similar to MediaSource API Demo
But when executing the line
var ms = new MediaSource();
And exception is throwed on Firefox and Internet Explorer
ReferenceError: MediaSource is not defined
In Firefox Support says that this feature is only enabled to Youtube and Netflix.
There is a way to handle this restriction?
In Chrome, I have not problem!
At time of writing, IE11 only has support when run on Windows 8.1 or above.
Firefox will only enable MSE when about:config param media.mediasource.enabled = true (this restriction will be removed eventually, once the FF implementation is globally stable). There is no way around this, so unless you are YouTube or Netflix, consider Firefox MSE as coming soon.
Firefox has been lagging behind quite badly when it comes to MSE support in their browser. Firefox Nightly build however now seems to be pretty close to working properly. It still has to go through nightly build and beta phase before it's released to the public, so expect a few months.
How to open the page in firefox browser to render HTML5 content?
MyObject = new ActiveXObject("WScript.Shell")
function RunFirefox() {
MyObject.Run("firefox file:///C:/Users/E836714/Desktop/template%20palettes/preview.html");
}
Here, I use url to open the Page. What I need was instead of url, I pass HTML to render in firefox.
The ActiveXObject object is used to create instances of OLE Automation objects in Internet Explorer on Windows operating systems.
So it only supports Internet Explorer on Windows. No other browser support is available till date for ActiveXObject.
Why would Flash work in IE 9 but not in IE 11? That is, why would Adobe Flash work with Microsoft Internet Explorer Version 9 and not work with Microsoft Internet Explorer Version 11?
I am using a small flash object in the index page of www.gelsana.com. It appears on one computer using IE 9 but not on another computer using IE 11. I first thought it might be an issue with a virus, but I ran a couple of anti-virus programs and I still have the issue on the computer using IE 11. Any advice?
What I would prefer to do instead of just not showing the little flash object is post some sort of message instead telling the user to download this or that. But since the cause of it not showing, I guess, might be for several reasons, I would need some sort of browser sniffer. I mean, it does not show at all in Chrome or Firefox.
Can the problem be fixed with using a later version of flash?
It seems to me that every browser and every version should have some way to show Flash. Is this not the case?
The SWF file I am using in the index.html is:
http://www.gelsana.com/assets/site_map.swf
I am not the author if this file. If I need to rebuild it as a silverlight project, I will need to decompile it. Do the tools exist that will allow me to do this? Is it possible to first decompile a flash project and then convert it into silverlight?
I think the ugly truth is that Flash is dead or dying and everything needs to be redone in HTML5. Say it isn't so. I hope there is an easier solution.
Is ActiveX Filtering turned on? Check for a not symbol (circle with a slash) in the address bar and click it to turn it off if so.
There is a standard from Adobe that in theory specifies opening PDF documents from a link clicked in a browser in a way to open specific sections (AKA "anchor", "named reference") of PDF document. This functionality should be of great help if one would like to refer to a specific portion of large PDF (such as some standard or specification).
However, from what I see now, support for this standard is close to non-existent.
For example, these links should open Scala Reference PDF at section 3.2.6, "Annotated Types":
http://www.scala-lang.org/docu/files/ScalaReference.pdf#subsection.3.2.6
http://www.scala-lang.org/docu/files/ScalaReference.pdf#nameddest=subsection.3.2.6
http://www.scala-lang.org/docu/files/ScalaReference.pdf#page=23
(Techincally, variant #3 should open page #23, which is essentially the same destination)
Is there a working way (may be with a couple of shims, proprietary wrappers or whatever else) to make this work on majority of systems? What is the usage share of Adobe Reader plugin, should I care about other systems?
If it's not possible, at least I'd like to find a working solution for every platform (i.e. Windows, Linux, Mac) that I could recommend to my site's users if they want to be able to use named destination links.
From what I've tested:
Windows, MSIE/Firefox/Chrome, Adobe Acrobat Reader plugin - all variants work with version 9+, but:
MSIE has a weird caching issue (i.e. anchor does not work until document was cached)
Older versions do not work
It has issues with link format: generally, it should be regular absolute link to a real web server, starting with "http://". Relative links, samba-style links (\\HOST\dir\file.pdf#something), anything else besides "http" (or probably, "https") scheme won't work
Windows, any browsers set up to run Adobe Acrobat Reader as a separate process - does not work
Windows, any browsers, FoxIt Reader - does not work
Windows, any browsers, CutePDF - does not work
Linux/Konqueror/Okular - only variant #1 works
Linux, any other browsers set up to run Okular or any other PDF viewer as external process - does not work (as browser does not pass any "#arguments" in a command line)
Any OS, Firefox 15+ PDF.js internal PDF viewer - does not work
I'd appreciate if you'd try it to test in various different combinations.
What seems to work in general is variant #4 but using the number of the page as in actual division into pages in the PDF document, in this case
http://www.scala-lang.org/docu/files/ScalaReference.pdf#page=31
The PDF document has page numbers that start from the content proper, after the table of content, but that numbering differs from the one to be used in #page=...