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.
Related
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
Recently we migrated to latest version of application which allows the user to open application in any browser.
Earlier it use to support Only IE browsers.
After migration many users still open the application in old browser.
Since the application is very slow in IE browser.We are looking for a solution that will automatically open the URL/Login Page in Chrome browser when user opens in IE browser.
i.e., when a user open URL in IE browser it automatically open the same URL in Google chrome browser.
Google Chrome Legacy Browser support allows this. Under the "Hosts to open in Alternative Browser" policy, put in an entry for the site you want to force to open in Chrome, preceding it with an "!". Example:
!https://www.somesitetoopeninChromeonly.com.
If i understand it correctly, the users open a page in IE and when they click an url on that page, it will open that URL in Chrome.
I guess, you can't do this. You can use target="_blank" to open a new tab in the same browser.
If you want to open a link from an application in chrome and not in IE, you can change the default browser to chrome. Click on Start, type the "default app settings" and change the default browser to chrome.
I think the best solution is to let the user open Google Chrome manually by informing about it.
It is possible however, to make a document called "chrome.hta" for example, with the contents shown below, and then link to it on another page. (This will only work in Internet Explorer, not Edge)
<script type="text/javascript" language="javascript">
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
var website = "http://example.com/";
oShell.ShellExecute(commandtoRun, website, "", "open", "1");
window.close();
</script>
The user now has to press "open" and "allow" after they click the link referring to the .hta file.
Now, on the page where you link to the .hta document, you can make the page detect the browser and adjust the link accordingly:
<a id="link" href="example.com">My Application</a>
<script>
if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
document.getElementById("link").href = "example.com/chrome.hta";
</script>
A bit late, but we have two different solutions for this:
We use a javascript: link to use ShellExecute to run a small exe helper application that checks if Chrome is installed, and if it is, open Chrome to the URL parameter, optionally with switches (e.g. --use-system-default-printer and on shared logon PCs, --incognito). This requires configuring special permissions for the site in Internet Options|Security.
Now we can also use the microsoft-edge: protocol to open sites in Edge.
You could also install your own protocol for opening sites in Chrome but you would need a helper application to re-write the URL. I have one written to add microsoft-edge-private: to open links in Edge in InPrivate mode.
To open the webpage in Microsoft Edge you can try the below code.
TEST
I have a simple web page that contain a widget
http://www.mccdepot.com.au/index6.html
This works on chrome, IE, firefox and safari.
But on a samsung TV I have the inbuilt browser does not show anything at all.
The browser is launched with an application called 'URL Launcher'
The model number is DM40E and it is using a browser called 'Hospitality browser' but the underlying browser is tizen.
When i checked the browser using whatbrowser.org it told me it was 'webkit nightly 537'
Can anyone help? any way to get these widegts shown on my tv.. I have no control of the widget code..
Any help is apprceiated
TV Model - http://displaysolutions.samsung.com/digital-signage/detail/431/DM40E
Ta
Vik
What happens if you try to access the iFrame source URL (https://cdnres.willyweather.com.au/widget/loadView.html?id=43747) directly?
If that works, it probably has something to do with the TV browser not supporting or purposely preventing iFrame content.
I have a PDF file embedded into a standard html web page.
<h3>Foo</h3>
<object id="foo" data="bigboundingbox.pdf"
type="application/pdf"
classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"> </object>
This currently renders in Internet Explorer using the Adobe Reader plugin on windows. Firefox and Chrome appear to be using their internal PDF rendering engines.
In all 3 cases the page displays with the Foo header visible above the contents of the PDF.
When a user tries to print the page (File->print), the PDF being rendered does not display in the resulting printed document in Internet Explorer or Chrome.
Firefox appears to display correctly.
I have tried using PDFObject in order to embed this with the same result
There are other posts recommending using PDF.js etc.. however I must support IE 7 and IE 8 and PDF.js will not work at all with 7 and works with limited success with 8.
Does anyone know why this happens and if there is anything i can modify so that it will print ?
You can use fpdf for that. Have a look at fpdf here
So, I have an HTML page that includes a Silverlight xap file which plays a video. It works correctly while running locally and on our DEV environment when using Chrome or FF. The issue is when I am trying to view the video on our DEV environment using Internet Explorer. When doing so, it prompts me to Display Mixed Content. Whether I hit Yes or No, the browser crashes. I am able to go into my options and Enable Display Mixed Content, which fixes the issue and the video shows up correctly on the DEV environment using IE. But, this is not a good solution for a client facing site. Is there a way around this message to prevent it from crashing the browser?
A workaround for this is to use JavaScript to open the HTML page that contains the video in a new window. The user will still be prompted to Display Mixed Content, but it will not crash the browser and the video will play.