How to open local html files in safari? - actionscript-3

I want to show the local HTML file in Safari because my users are able to send their HTML files as a PDF in the options menu
For this reason:
var htmlFile:File = File.documentsDirectory.resolvePath("WebWin//invoice//" + "billing.html");
if(htmlFile.exist)
{
trace("logo is exist")
navigateToURL(new URLRequest(htmlFile.url), "_blank");
}
didn't work on mobile devices (works only on Windows)
also when I share local HTML files with Share ANE,
Share.service.shareFile( htmlFile.url, "html.html", "text/html" );
on iOS, it doesn't show Safari, or when I select Chrome, it prompts me Chrome cannot handle this link!
can you help me, how can I solve this problem?

Related

window.print() is not working in chrome 77 version

I am facing one issue since my chrome browser is updated to version 77.
Initially window.print() is working fine, but once I open a page where it includes embedded PDF using <embed> tag, window.print() stopped working. Using Ctrl+P shortcut it opens the print popup but when I execute window.print() in javascript it doesn't work.
I have executed window.print() command in console, it directly returns undefined.
There might be a some changes in Chrome 77 release as per this thread https://support.google.com/chrome/thread/14107571?hl=en
Does any one have face this issue ?
Please help.
Looks like this is related to Chrome settings issues, because turning off chrome://flags/#mime-handler-view-in-cross-process-frame fixing that issue.
For someone that did not know how to turn off that, please do this:
Open new tab on chrome, and type chrome://flags/
You will have Experiments page opened.
Then type: Mime on the search bar on that page.
That will show you: MimeHandlerView in cross-process frame
Change that value from: Default to: Disabled, then it will ask you to relaunch the chrome.
After the chrome restarted, the printing function will work fine.
I am facing some what similar issue - once the pdf file is rendered, by the chrome pdf viewer, the window.print() starts returning undefined.
More detailed description - A pdf file is rendered into the tab, user hits back and then print() stops working. It is important that all is executed in the same tab.
$(document).ready(function () {
var URL;
$('#Print').click(function () {
$('#embed').remove();
URL= 'url';
setTimeout(cPrint, 100);
});
function cPrint() {
window.print();
$('#div').append('<embed id="embed" src="' + URL + '" />');
}
});

Safari: in pinned tab, download attribute with data href not working

In Safari 11/12, I have an tag with href="data:" and attribute "download" to save the file when the link is clicked.
<!DOCTYPE html>
<html><body>
<a href="data:text/plain;charset=utf-8,Hello" download="hello.txt">
Click me
</a>
</body></html>
This works fine in Chrome and Firefox, and also in an unpinned tab in Safari. Clicking on the link downloads the text "Hello" into a new file called hello.txt. However, in a pinned tab in Safari, the download attribute seems to be ignored and Safari opens the data in a new tab.
To see this you need to serve the above HTML code from a web server. If you just save the file and open it with a "file://" URL, it works as expected.
I have tried using a Blob instead but the behaviour was the same.
I have tried changing the mimeType to "application/octet-stream" which was a suggestion I found to a similar question. This does cause the data to be downloaded, but the filename is always "unknown.txt". This isn't suitable as I need to have control over the filename and extension (it's not hello.txt!)
As an extra note, the behaviour is actually different in Safari 11 and 12 but neither is working properly. In 11, the data is opened in a new tab. In 12, it opens a new tab but shows an error opening the data.
This looks like a bug in Safari to me. Can anyone suggest a workaround?
Thanks
It appears it is a well known bug and the download attribute is not yet supported by Safari (webkit).
https://bugs.webkit.org/show_bug.cgi?id=167341
https://caniuse.com/#feat=download

How to Automatically redirect website IE browser to Chrome browser?

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

ng-file-upload: Upload file from mobile Firefox browser

I use ng-file-upload with AngularJS in my web app and it works great in PC browsers. However, when I open the app in Android Firefox, I am not able to upload files. But it works with Chrome. Nothing comes up when I click the file select button.
Is there anyway to make file upload does not work with FIrefox?
Thank you.

HTML5 drag-drop uploads

Does anybody know how to use HTML5 to achieve uploads by drag-drop files form desktop?
I have found the following references:
Selecting files using drag and drop (2017-08) on developer.mozilla.org
Drag and drop file uploading using JavaScript the article states that the api was changed and links to The File Api has changed (2010-09)
html5-drag-and-drop-multiple-file-upload (2017-11 returns 404) on http://www.appelsiini.net/ (is still live)
but is there a solution that can run on all platforms: Firefox, Chrome and Safari?
Many thanks!
Sorry, at the moment there is no cross browser solution available.
Current Browser Implementation Issues
FF, Safari, Chrome, IE (Cross-Browser Issues)
No recursive folder uploading -- as a matter of fact, no folder uploading at all. While this isn't a show stopper, it does seem kind of silly to allow a user to select a folder in the file upload input box if the browser won't send all the files inside that folder too.
Firefox 3.6.*
This browser supports file drag and drop, however the implementation is quite possibly the worst ever conceived. In order to upload a file that the user dropped, we have to read the entire file into memory and then send it over Ajax to our servers. This works fine for drops of around 10MB. If you try that same operation with a 400MB file, forget it!
Firefox 4.* (Beta)
The Mozilla developers are quick ones -- they realized the problem with their previous implementation and have created a whole new way to implement drag and drop uploading. The FormData object is a new JavaScript object that allows a web developer to insert file uploads directly into an Ajax request without reading the files into memory first. I was really excited about this and promptly downloaded Firefox 4 which is in its 2nd beta. After playing around with it for less than 5 minutes, I strongly discourage you from trying it yet. My system became incredibly unstable and slow and development was a major pain due to lack of support for Firebug.
Chrome (latest)
This browser is by far the best in its implementation! Simple and straightforward, my only complaint here is that you can't upload a folder and its contents via drag and drop.
Safari 4.* & 5.*
Since Safari is built on top of WebKit just like Google Chrome, I expected it to work just as well. Wow, was I mistaken! I tried this in both Safari 4 and Safari 5. While dragging and dropping multiple files into the window works, Safari sends the first file multiple times, instead of sending all the files. Talk about a MAJOR bug. To make it even more interesting, if the user clicks on the drop location, they can select multiple files to upload using the standard file selection dialog -- and that works as expected! I can't wait for Safari to fix this issue.
Internet Explorer
To be honest, I haven't even bothered trying to do drag and drop uploads in Internet Explorer yet. Trying to support IE is a pain due to lack of good development tools and a non-conforming JavaScript engine. Since I haven't been able to get all the preferred browsers to play nice, I can't imagine Internet Explorer will be even close.
source
I would defiantly look into running Plupload. It allows great browser capability and supports multiple file drag and drop in HTML5 browsers that support FileReader.
So lets say for example you dont have html 5 it will deprecate down to flash / gears / silverlight depending on what that individual has installed.
Here's the compatibility chart:
http://www.plupload.com/index.php
It has an option called droparea: "somediv" that allows you to drag files into it and automatically cue up a file upload.
Let me know if you need any help setting it up.
Here is a simple example. If you drag an image over the red div it appends the image to the body. I've confirmed it works in IE11, Chrome 38, and Firefox 32. See this Html5Rocks article for a more detailed explanation.
<div id="dropZone" style="width: 100px; height: 100px; background-color: red"></div>
<script>
var dropZone = document.getElementById('dropZone');
// Optional. Show the copy icon when dragging over. Seems to only work for chrome.
dropZone.addEventListener('dragover', function(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
});
// Get file data on drop
dropZone.addEventListener('drop', function(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files; // Array of all files
for (var i=0, file; file=files[i]; i++) {
if (file.type.match(/image.*/)) {
var reader = new FileReader();
reader.onload = function(e2) {
var img = document.createElement('img');
img.src= e2.target.result;
document.body.appendChild(img);
}
reader.readAsDataURL(file);
} } });
</script>