3

I need to alert users browsing with Chrome that they need to open a page using IE, as it allow open a Network Folder inside iframe.

But I don't want to detect browser, is there a way to detect this feature?

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
Felipe Pessoto
  • 6,855
  • 10
  • 42
  • 73
  • are you talking about WebDav? – epoch Jun 13 '14 at 12:46
  • I dont know what is WebDav. I just need to show a alert to user when using a browser that doesnt support iframe pointing to local driver – Felipe Pessoto Jun 13 '14 at 12:51
  • 2
    can you provide some code example, what are you trying to do with IE? – VMAtm Jul 16 '14 at 12:07
  • Its just a I want to detect via javascript it the browser support it – Felipe Pessoto Jul 16 '14 at 12:08
  • You have to detect browser and add-ons, as the Chrome doesn't support this feature (http://stackoverflow.com/a/2436256/213550) – VMAtm Jul 16 '14 at 12:10
  • Actually this add-on doesnt do what I want. I want to show the folder, not open a file – Felipe Pessoto Jul 16 '14 at 12:11
  • 1
    Wouldn't, in theory, creating an iframe pointing to that network folder and detecting onload if the document of that iframe loaded be the answer? But then opening network share using any browser should work. – eithed Jul 16 '14 at 12:24
  • @Fujiy, could you create a snippet on whats done till now? – naveen Jul 16 '14 at 12:49
  • @Fujiy What version of IE does `` work for you in? I tried it out and it wasn't working for me in IE10. – pseudosavant Jul 22 '14 at 23:14
  • Try using VBScript in windows that will work better, you are trying the wrong way around. what you are asking is not possible without installing some third party bridge/plugin in browser. don't complicate with iframe; as if possible using JavaScirpt we need not use iframe. – MarmiK Jul 23 '14 at 13:36

1 Answers1

3

No, you cannot detect this feature (if you can call it that, allowing web pages to display local folders in a frame is a very bad idea). The same-origin policy prevents you from knowing what was loaded into the frame so you cannot distinguish a network folder from an error page. Best you can do is checking how long the frame takes to load:

var start = new Date().getTime();
var frame = document.createElement("iframe");
frame.addEventListener("load", function()
{
  if (new Date().getTime() - start < 100)
    alert("Looks like the network folder didn't load, try using a less secure browser?");
}, false);
frame.src = "file://mynetworkpath/folder";
document.body.appendChild(frame);

In my tests it took Chrome around 30 milliseconds to load the error page, the code above sets 100 milliseconds as threshold just to be sure. Loading a network folder should always take considerably longer. This code didn't work in Firefox 30, for some reason the load event isn't fired there. This might be a security precaution but I don't really know that.

Alternatively, you can try loading an image that is known to exist:

var img = new Image();
img.onload = function()
{
  // Can display the frame
};
img.onerror = function()
{
    alert("Try using a less secure browser?");
};
img.src = "file://mynetworkpath/folder/pixel.gif";

Note that neither solution will allow distinguishing between "browser won't let me access network folders" and "network folder is inaccessible, probably no network connection."

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126