local link in HTML - html

This is HTML link to google:
Google
And it work fine
This is a link to my local file:
Local
And its not working, why?
If this is some sort of security issue, so how can I work around it? It's just for my own testing.

This sort of link to a local file will work in some browsers as long as the HTML is also called from a local file. If not, it's a security vulnerability. It won't work at all in webkit based browsers.
See <A>nchor Link to Local File? (<a href='file:///{path}'>DEAD LINK</a> not working in FireFox but in IE)
And Cross-browser link to file on local system

Due to Mozilla’s security model(as well as other modern browsers too), file://-links to local files on your computer or files on a network share do not work on (non-local) web pages; a click on such a link just does nothing. Links to local files could be useful on intranet sites like wikis.
There's an extension named LocalLink(http://locallink.mozdev.org/) for FireFox (and Thunderbird), that adds a new entry “Open Link in Local Context” to the link’s context menu. After you have installed the extension from https://addons.mozilla.org/firefox/addon/281 , you can open file://-links by right click on the link and select “Open Link in Local Context > Current Window”.

Related

Download attribute html link just opens to a new page?

I am trying to allow users to download a file. I took this example here:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_a_download
When I click their w3 photo I get a jpg download in Chrome.
However, when I copy their html onto my local machine into a plain static html file, I open the html file in Chrome, then I attempt to download that file, and then Chrome just opens up the photo in a different window without downloading anything. Anyone know what's the problem?
My code (which is almost the exact same):
<!DOCTYPE html>
<html>
<body>
<h1>The a download attribute</h1>
<p>Click on the image to download it:<p>
<a href="images/myw3schoolsimage.jpg" download>
<img src="images/myw3schoolsimage.jpg" alt="W3Schools" width="104" height="142">
</a>
<p><b>Note:</b> The download attribute is not supported in IE or Edge (prior version 18), or in Safari (prior version 10.1).</p>
</body>
</html>
I downloaded the w3 image locally onto my computer so it should'n't be a cross site origin issue
You would be better served studying almost anywhere but w3schools.
But more to your problem, are you running a webserver locally, or depending on file:/// links?
incognito mode will not impact your testing in any way.
A quick glance at google results for ‘download from file:/// link fails’ will show that there are an host of issues surrounding local file downloads and the file:/// links, especially on chrome.
This is not surprising - chrome is a browser not a web server.
Where the semantics of such ‘downloads’ are inconsistently defined for browsers, the semantics of true downloads are well defined, and their behavior consistent in a true service context.
To further both your understanding of these tools and the goals of your project, I strongly encourage you to download and install a webserver for your platform and learn the basics of it’s configuration and deployment.
You will not regret having done so.

PDF not opening in my browser in production

I have a Razor MVC application that contains a link to open a PDF stored on a file server. My code works when I run it in Visual Studio but is not working when I try it on production on the same computer. I click the link and nothing happens, I can see the path when I hover over it though. There are no errors or anything. I've tried all browsers but only really care about IE.
View
Image when I hover over the link
Any ideas why this is not working?
Filesystem URLs from remote pages (i.e. pages on other protocols like http:// or even other directories in the file system) are blocked by modern browsers for security reasons.
Here is a page describing the behaviour for Firefox (along with reasons why it exists).
Internet Explorer has joined the ranks of these modern browsers:
By default, Internet Explorer prevents navigation to Uniform Resource
Identifiers (URIs) using the "file:" protocol when the current URL
matches the following conditions:
The current URL is opened in the Internet zone or the Restricted Sites zone.
The current URL uses a protocol other than "file:".
This is a security measure designed to
prevent malicious sites from accessing system file objects.
This can be changed, but only on a per-client basis (see the MSDN article for details.)

HTMl anchor link to local file

I'm testing a locally run web app and am trying to use anchor tags to link to log file output on my C: drive. The href value that's generated for the anchor is in the standard URI format "file:///C:/outbox/myLog.txt". But, when I try to click the anchor, the link doesn't go anywhere, I have to right-click and copy the link into the address bar or to a new tab. I'm not sure why copying the link works whereas the link itself isn't clickable. Any help is appreciated.
Is this the case on different browsers? What is your browser / OS? We've seen this as a fault on Windows XP on both IE and Firefox browsers and may be nothing to do with your code
From my understanding, you can't link to file:/// from an HTML doc for security reasons. You might want to try this chrome extension.

Launch file:// from Firefox or Chrome

I am looking for a way to launch a file located on our local file network for use via our local intranet using Firefox or Chrome.
The link works well in IE:
View Report
but in Firefox it shows:
View Report
is there a way to get the link to render properly?...Just a simple click from a href tag.
For Chrome, a new extension was just posted today! It's called LocalLinks and it replicates the functionality of the locallink add-on for Firefox! You'll find it on the Google Extensions page, or you can get to it directly here:
https://chrome.google.com/extensions/detail/jllpkdkcdjndhggodimiphkghogcpida
Enjoy!
This is not enabled in firefox for security reasons (remember that most computers have files and applications of a sensitive nature located in similar locations, like C:\System\Windows)
you can try adding this to the user.js file for any user that needs to be able to access these links:
user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "file:///[[PUT SERVER NAME HERE]]";);
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
Just remember that this is a security risk.
Firefox seems to want file://///Start/Of/My/Network/file.xlsx
Chrome and IE handles that too.
file://Start/Of/My/Network/file.xlsx appears to work in Chrome as well, sometimes firefox hics up on it..
There is the LocalLink add-on for firefox. It uses a context menu though...
Use IE tab (available for Chrome and Firefox) and set that to handle all links of the form file:/// by adding an autourls entry like this:
r/file:///.*
Technically this isn't opening the file in the original browser, but it gives you all the windows explorer integration you'd expect from whatever IE version you've got installed when dealing with local file links. I would advise against doing this except in cases when the browser isn't being used to access the web - e.g. for viewing internal wiki or intranet pages, due to the obvious security risk.

Cross-browser link to file on local system

I would like to make a link from a web page to a file on a local filesystem and make it work in all browsers (or at least in Internet Explorer, Firefox and Chrome).
For example, the following works in Internet Explorer:
Info here
but not in Firefox and Chrome.
Is there a way to make a link that works in all browsers?
Or a way to use javascript to detect which browser it is and then display the appropriate link based on the filename?
Links to local files on pages that were retrieved via HTTP(S) are deliberately disabled in Mozilla/Firefox, because they can be a security risk, and have been used in attacks in the past.
You can override this behaviour, however. For details, see this article in MozillaZine.
try prefixing your url with file:///