I have a problem with:
href="file://"
Well I want to point a link in html to file, in browser if I write like
file:///K:/filename.pdf
It works to open a file, but if I point it to:
href="http://file:///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf"
It doesn't work. link is changed to:
file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
The colon after file disappears. Any suggestions as to what to do?
The reason your URL is being rewritten to file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf is because you specified http://file://
The http:// at the beginning is the protocol being used, and your browser is stripping out the second colon (:) because it is invalid.
Note
If you link to something like
yourfile.pdf
The above represents a link to a file called k:/yourfile.pdf on the k: drive on the machine on which you are viewing the URL.
You can do this, for example the below creates a link to C:\temp\test.pdf
test.pdf
By specifying file:// you are indicating that this is a local resource. This resource is NOT on the internet.
Most people do not have a K:/ drive.
But, if this is what you are trying to achieve, that's fine, but this is not how a "typical" link on a web page works, and you shouldn't being doing this unless everyone who is going to access your link has access to the (same?) K:/drive (this might be the case with a shared network drive).
You could try
test.pdf
test.pdf
test.pdf
Note that http://file:///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf is a malformed
%20 is the space between AmberCRO SOP.
Try -
href="http://file:///K:/AmberCRO SOP/2011-07-05/SOP-SOP-3.0.pdf"
Or rename the folder as AmberCRO-SOP and write it as -
href="http://file:///K:/AmberCRO-SOP/2011-07-05/SOP-SOP-3.0.pdf"
Share your folder for "everyone" or some specific group and try this:
Download PDF
Although the ffile:////.exe used to work (for example - some versions of early html 4) it appears html 5 disallows this.
Tested using the following:
<a href="ffile:///<path name>/<filename>.exe" TestLink /a>
<a href="ffile://<path name>/<filename>.exe" TestLink /a>
<a href="ffile:/<path name>/<filename>.exe" TestLink /a>
<a href="ffile:<path name>/<filename>.exe" TestLink /a>
<a href="ffile://///<path name>/<filename>.exe" TestLink /a>
<a href="file://<path name>/<filename>.exe" TestLink /a>
<a href="file:/<path name>/<filename>.exe" TestLink /a>
<a href="file:<path name>/<filename>.exe" TestLink /a>
<a href="ffile://///<path name>/<filename>.exe" TestLink /a>
as well as ...
1/ substituted the "ffile" with just "file"
2/ all the above variations with the http:// prefixed before the ffile or file.
The best I could see was there is a possibility that if one wanted to open (edit) or save the file, it could be accomplished. However, the exec file would not execute otherwise.
Related
I'm trying to place a button that, when clicked, downloads the file aaa.txt.
I have that file on the same folder as my index.html.
I've tried this:
<a href="aaa.txt" download>aaa</a>
<a target="_blank" href="aaa.txt" download>aaa</a>
aaa
But none seem to work. When clicked, chrome downloads a aaa.htm and says "error:file not found"
Also, I'm on a private server, not just running the html file.
It is quite simple you just need to specify the route more accurately, by adding a forward slash "/" before aaa.txt
<a href="/aaa.txt" download>aaa</a>
for more info, you can refer w3school
It deepens from where you generate the link:
/ = root of the current app (/);
./ = current directory (/subfolder/subfolder/);
../ = parent of the current directory (/parentFolder/).
Means if you have only a index.html file in root then you need only /filename.ext. In your case:
aaa
I can download simple links (eg 'x.jpg').
But some links can't download whatever I do.
Like this :
<a href="/instagram.fist4-1.fna.fbcdn.net/vp/a122a6b090b0d08fb29054a58e4ba1d8/5E6244BC/t51.2885-15/e35/73020566_1906916579453459_3610340591421234923_n.jpg?_nc_ht=instagram.fist4-1.fna.fbcdn.net&_nc_cat=1&se=7&ig_cache_key=MjE1Mzk3NTkyNTE1NTgyMjI1NA%3D%3D.2" download>
download
</a>
Results :
***************************
Main Result : downloaded (73020566.html) (fail! , no file)
if i include to end of filename '.jpg' : same result,
include to start of filename 'https://' : this photo openning in tab.
***************************
I would appreciate it if someone who knows the solution helps
As j08691 stated, using the download attribute won't work since your download is cross-origin. However, you could try download.js, which uses AJAX to load the file content into a blob and download it: http://danml.com/download.html
The download attribute only works for "same-origin URLs, or the blob: and data: schemes." So you can't use it when linking to another site. Also, "/ and \ characters are converted to underscores (_). Filesystems may forbid other characters in filenames, so browsers will adjust the suggested name if necessary."
I have a URL www.foo.com/bar/hello/world Can I use href= in such as way:
LinkText
In other words, because of the versioning repository I use for work, only the sublink /hello/world of the final URL will the same when I push the site live.
For reference, see the docs
However, in href, you can either use an absolute URL, such as https://www.foo.com/bar.html or, relative, something like /bar.html, where / refers to the webserver root (but not webserver's system root), or, you can use bar.html which points to a file in the same directory level.
Basically you want to have a /hello/world link, it will point to www.foo.com/hello/world.
If you want it www.foo.com/hello/world to point at www.foo.com/bar/hello/world, you can either rewrite the URL on the server, or, redirect the users to www.foo.com/bar/hello/world
For URL rewriting, see your appropriate webserver docs
Only if the source code is located in 'http://www.foo.com/bar' and then it needs to be going to a valid file extension to execute an action:
LinksText
What is the difference between the Following html links
<a href="home.aspx">
<a href="../home.aspx">
<a href="~/home.aspx">
<a href="home.aspx">
This redirects to home.aspx where home is in the same path location as the current page. So lets say I click that link while I am on http://example.com/subpath/about.aspx, I would get redirected to http://example.com/subpath/home.aspx. Likewise for http://example.com/subpath/subpath/about.aspx I would get redirected to http://example.com/subpath/subpath/home.aspx.
<a href="../home.aspx">
This works very similar to the one above, but it always goes one level up in the path. The two dots means "one level up from here". Using the same examples:
http://example.com/subpath/about.aspx -> http://example.com/home.aspx
http://example.com/subpath/subpath/about.aspx -> http://example.com/subpath/home.aspx.
You can use it multiple times, too, if you need, such as <a href="../../home.aspx">.
<a href="~/home.aspx">
The previous two are standard things that the browser understands and supports. This one is handled by ASP.NET. The tilde (~) specifies the virtual root of your application. How this behaves is entirely dependent on how your application starts up and what the "root" of your site is. Put simply, the virtual root means "the top level location in your ASP.NET application". So, assuming that your site is configured so that the virtual root is the domain, it would behave like this:
http://example.com/subpath/about.aspx -> http://example.com/home.aspx
http://example.com/subpath/subpath/about.aspx -> http://example.com/home.aspx.
This is my implementation of tweet button
<a href="https://twitter.com/share?url=generated_url"
class="twitter-share-button"
data-text="Hi, you can see my presentation on this link">Tweet
</a>
There is something like list of presentations and every one has tweet button and itself generated url to share.
It working well, post tweet like I want - text and url. But, when I tweet via this button, link on twitter is unclickable. What is wrong?
EDIT:
unclickable - showed as plain text, example screenshot:
The code is correct, but the links with "localhost" are not clickable.
I had the same problem until I tested with a "live/public" link.
Your generated_url should not contain localhost, but http ://www . yoursite . com / data
I think this page on the twitter dev docs and this question can help a lot. For what i found there, it would be something like this:
<a href="https://twitter.com/share"
class="twitter-share-button"
data-lang="en"
data-url="http://this.url.com/foo/bar">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>