javascript - Not allowed to load local resource: file -


i using code below create link, when click on link in ie it's working , i'm able open url not in chrome.

test<a href='#'onclick=window.open('file:\\160.53.112.171\mytest\cons\4.1\displaydata.htm','_self') > 

below error message displayed on chrome's console.

not allowed load local resource: file:file:///c:/160.53.112.171mytestcons%04.1displaydata.htm in chrome.

for landing here , working in asp.net:

i having same issue (not allowed load local resource) in every browser except ie.

my workaround have anchor direct handler & include query string path:

<a href='handler.ashx?file=//server_name//dir//filename.pdf' /> 

then handler write file response (opens in new tab desired _self):

public void processrequest (httpcontext context) {          if (context.request["file"] != null && !string.isnullorempty(context.request["file"].tostring()))         {             try             {                 context.response.clear();                 context.response.clearcontent();                 context.response.clearheaders();                 //whichever content type you're working                 context.response.contenttype = "application/pdf";                  //encode path when set href of anchor, decode                 string file_name = httputility.urldecode(context.request["file"].tostring());                 context.response.transmitfile(file_name);              }             catch { }         } } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -