HTMl anchor link to local file - html

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.

Related

OneNote to open link in Chrome without Chrome being default

I have a very simple question I could not find answer for myself: I want links in OneNote to open in Chrome.
Note that the default browser is IE and I cannot change it (not admin etc).
Tried: "chrome_path url" - didn't work. Everything I could think about didn't work.
Please provide explicit solution so that link from within OneNote opens in Chrome rather than in IE.
To note, there are multiple links, so batch file won't do in this case.
Thank you in advance!
I had a little go with testing some ideas that I had though I'm very new to OneNote. It's easy enough to open Chrome from a hyperlink:
Select text to link
Add link
Select the file icon and navigate to chrome.exe. In my instance - C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
I believe you cannot pass arguments to the exe as it is considered a security issue. This certainly used to be the case and I'm not sure if they have modified their thinking since. The only way I can think of is to create a batch file which includes your ideal website and link to the batch file:
"start chrome http://www.youtube.com"
I found two ways to do it, though neither is the perfect:
There is a 3rd party OneNote add-on which adds more browsers in the right-click menu. Though it is not free and maybe can't be installed on restricted computers.
It works only on OneNote docs which are saved onto Onedrive. Open the OneNote page which has the links right in the Chrome, not in the desktop app. Then any links you click will open in the same browser. You can get the address of the OneNote page by clicking on 'Copy Link to Page' in OneNote app, then paste it to a notepad. Copy the first url to Chrome's address bar.
For those who has admin right, this problem can be solved by following Make Chrome your default browser. It is set at machine level, not onenote level.

How to make chrome download instead of try to display a file

I'm trying to access a document template (.dot) that's linked from a company portal, using chrome. When I click on the link, the browser shows me a bunch of garbage. Is there a setting to force chrome to download this type of file and open it in word?
Example of garbage:
For HTML5:
<a href='file.dot' download>Click here to download</a>
'Download' attribute documentation can be read at:
http://www.w3schools.com/tags/att_a_download.asp
Supported since chrome 14.0.
EDIT: However this is controlled by the site. As for client-side settings, i think only changing the .DOT extension to match Word files in Windows, and perhaps even that won't work if chrome uses its own list.
In any case, you can right-click and "Save file as...", but yes, it's annoying.

How to open a windows folder when clicking on some link on a HTML page using Python

I am writing following program :
***import os
filepath=r'C:\TestData\openfolder.html'
abc=open(filepath,'w')
abc.writelines('<html><head></head><body>')
abc.writelines('First Link\n')
abc.writelines('</body></html>')***
What I want to do is if I click First Link on a browser, I should be able to open the folder having path as "Filepath". os.startfile works perfect for opening a folder but I don't know how to implement this inside some link.
Thanks.
Try to use URI with file: scheme like file:///C:/TestData/openfolder.html in your html:
Link to test data
Here is article on using file URIs in Windows.
UPD (extraction from comments): Each browser has its own way to handle such urls. At least Internet Explorer 8 under Windows 7 opens links in Windows Explorer as was required by jags.
Finally, for dynamic pages the web server is required. If one is needed take a look at discussion on creating simple web services using python.
You can't. Clicking a link to a file in a browser will not launch the application associated with that file type on the OS. You can apparently do some funky stuff with JavaScript to launch particular filetypes with particular applications (see here: http://forums.devshed.com/asp-programming-51/launching-ms-word-to-open-file-from-a-hyperlink-55714.html) but apart from that the web browser is not the file browser.
Link Text
Replace FOLDER_PATH with the path of the folder you want to open in explorer.
Alain's answer works.
<'a href="FOLDER_PATH" target="_explorer.exe">Link Text<'/a>
I removed the tick marks at the beginning and end, and found that it works in
Internet Explorer - opens a Windows Explorer window
Firefox (Windows and Linux), but opens a new tab - same as target="_blank"
Chrome - opens a new tab like Firefox
I also noticed that / and \ (forward and backward slashes) are equal in html links - they can even be mixed.

local link in 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”.

zip file link not download from IIS in internet explorer 8 but instead opens as gibberish

i have a .zip file sitting on an IIS 6 webserver.
i have an html file with a link to that zip file like this:
Download File
When you open the page and click the link in firefox or chrome, you get the Open or Save dialog box as expected.
When you do the same in Internet Explorer 8, you navigate to a new page that displays the "contents" of the zip file as text (unreadable characters). This happens on at least 3 machines that were tested.
Any idea why this would be happening in IE or what i need to do to fix it?
Changing IE settings is not an option since we do not control the settings of who goes to our site. Changing the HTML or javascript on the page with link is an option.
Thanks for the help!
You may need to set the MIME type of the file. To do so, go to IIS6 Manager for the website. Go to Properties for the site (right-click on the website name for Properties in the menu). Click the HTTP Headers tab. Click the MIME Types... button.
From there, you should be able to add .zip as an extension. I'm not entirely sure which MIME type will work best, but application/zip and application/x-zip are two options to try.