开始下载 [英] Start Download

查看:59
本文介绍了开始下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法让用户从我的网站上获取一个文件,然后将
保存到他的电脑上。


我遇到了这个方法:使用带有onclick事件的span标记,例如:


< span

onclick =" document.location.href =''http:/ /mysite.com/files/myfilename'';return

false;" style =" cursor:pointer;

text-decoration:underline;"> myfilename< / span>


唯一的问题是文档在浏览器中打开并且我想要用户获取ftp下载并指定文件应该下载到哪个页面




感谢任何帮助。


迈克

解决方案



mike写道:

我正在寻找一种方法让用户从我的网站上获取文件并将其保存到他的电脑中。

我遇到了这个方法:使用带有onclick事件的span标记,例如:

< span
onclick =" document.location.href =''http://mysite.com / files / myfilename''; return
false;" style =" cursor:pointer;
text-decoration:underline;"> myfilename< / span>


这似乎还有很长的路要走。它提供了相同的

功能:


< a href =" http://yoursite.com/files/filename">文件< / a>


为什么要使用span标记来解决所有不必要的麻烦?

唯一的问题是文档在浏览器中打开并且我<希望用户获得ftp下载并指定文件应该下载到哪里。


有些浏览器可以在点击链接时自动打开某些文件

。例如,pdf,word文档等。在

这些情况下,最好建议用户

"右键单击>将目标另存为......在FireFox中,它更像是

"右键单击>保存链接为...。

任何帮助表示赞赏。

Mike



> ....右键单击>将目标保存为...。


因此,当用户点击它时,我不能自动获得此功能吗?


有些用户不知道他们可以做这种事情。


Mike


web.dev在2005年11月2日下午12:27发表以下内容:

mike写道:


< snip>

唯一的问题是文档在浏览器中打开,我希望用户获得一个ftp下载并指定文件应该下载到哪里。



某些浏览器可以在单击链接时自动打开某些文档
。例如,pdf,word文档等




这不完全正确。浏览器可以或不能直接在浏览器中打开

与浏览器的设置方式直接相关

up。默认情况下,基于Mozilla的浏览器无法在

浏览器中打开pdf文件。对于Word文档也是如此。


IE6,在我的电脑上,无法在浏览器中打开Word文档。


浏览器的功能是什么文件完全直接与浏览器的设置方式有关。

在某些情况下,最好建议用户
右键单击>将目标另存为......在FireFox中,它更像是
右键单击>保存链接为...。




不是某些情况,所有情况。


-

Randy

comp.lang.javascript常见问题 - http:// jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /


I was looking for a method for the user to get a file from my site and
save it to his computer.

I ran across this method: use a span tag with an onclick event like:

<span
onclick="document.location.href=''http://mysite.com/files/myfilename'';return
false;" style="cursor:pointer;
text-decoration:underline;">myfilename</span>

Only problem with that is the document gets opened in the browser and I
want the user to get an ftp download and specify where the file should
get downloaded to.

Any help is appreciated.

Mike

解决方案


mike wrote:

I was looking for a method for the user to get a file from my site and
save it to his computer.

I ran across this method: use a span tag with an onclick event like:

<span
onclick="document.location.href=''http://mysite.com/files/myfilename'';return
false;" style="cursor:pointer;
text-decoration:underline;">myfilename</span>
That seems to be a long way to do things. It provides the same
functionality as:

<a href = "http://yoursite.com/files/filename">File</a>

Why go through all the unnecessary trouble with a span tag?
Only problem with that is the document gets opened in the browser and I
want the user to get an ftp download and specify where the file should
get downloaded to.
Some browsers can open certain documents automatically within itself
when the link is clicked. For example, pdf, word documents, etc. In
some situations as these, it''s just best to advise the user to
"Right-click > Save target as...". In FireFox it''s more like
"Right-click > Save link as...".
Any help is appreciated.

Mike




> .... "Right-click > Save target as...".

So, can''t I just get this functionality automatically when the user
clicks on it?

Some users don''t know they can do this kind of thing.

Mike


web.dev said the following on 11/2/2005 12:27 PM:

mike wrote:

<snip>

Only problem with that is the document gets opened in the browser and I
want the user to get an ftp download and specify where the file should
get downloaded to.


Some browsers can open certain documents automatically within itself
when the link is clicked. For example, pdf, word documents, etc.



That is not entirely true. What the browser can, or can not, open
directly in the browser is directly related to how the browser is set
up. Mozilla based browsers, by default, can not open a pdf file in the
browser itself. Same for Word Documents.

IE6, on my PC, does not open Word Documents in the browser.

What a browser does with a file is totally, and directly, related to how
the browser is set up.
In some situations as these, it''s just best to advise the user to
"Right-click > Save target as...". In FireFox it''s more like
"Right-click > Save link as...".



Not some situations, all situations.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


这篇关于开始下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆