允许客户端在自己的系统上打开文件 [英] Allowing clients to open files on their own system

查看:75
本文介绍了允许客户端在自己的系统上打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 http://www.sundry上有一个小搜索页面.ws / search.html

我想添加一个部分,允许我在我的

计算机上打开文件,而不必去文件>打开。这样只是稍微好一点。比如说,这是我写的代码:

< form id =" file">

< table id =" file-open" summary ="用于打开本地文件">

< colgroup span =" 2">< / colgroup>

< tbody>

< tr>

< td>

< p>文件:< / p>

< / td>

< td>

< input type =" file" ID = [上载箱"大小= QUOT; 20" maxlength =" 255"

onchange =" window.location.href = forms [3] .elements [0] .value" />

< / td>

< / table>

< / form>


它适用于IE 6 SP2,但不适用于Firefox 1.6或Opera 8.0。 Opera

什么都不做,Firefox给我一个错误,C不是一个

注册协议。有人可能会告诉我为什么这不是
工作,以及如何修复它?


TIA,

Ian

-
http://www.bookstacks.org /

I''ve got a small search page at http://www.sundry.ws/search.html and
I would like to add a section that allows me to open files on my
computer, instead of having to go to File > Open. It''s just slightly
easier that way.

This is the code I''ve written to do that:

<form id="file">
<table id="file-open" summary="For opening local files">
<colgroup span="2"></colgroup>
<tbody>
<tr>
<td>
<p>File:</p>
</td>
<td>
<input type="file" id="upload-box" size="20" maxlength="255"
onchange="window.location.href = forms[3].elements[0].value" />
</td>
</table>
</form>

It works in IE 6 SP2, but not in Firefox 1.6 or Opera 8.0. Opera
does nothing, and Firefox gives me an error that "C is not a
registered protocol". Could someone possibly tell me why this isn''t
working, and how to fix it?

TIA,
Ian
--
http://www.bookstacks.org/

推荐答案

Ian Rastall写道:
Ian Rastall wrote:
我在 http://www.sundry.ws/search.html 和
我想添加一个允许我在我的
计算机上打开文件的部分,而不必转到文件>打开。这样就更容易了。

这是我写的代码:

< form id =" file">
< table id =" file-open" summary ="用于打开本地文件">
< colgroup span =" 2">< / colgroup>
< tbody>
< tr>
< td>
< p>文件:< / p>
< / td>
< td>
< input type =" file" ID = [上载箱"大小= QUOT; 20" maxlength =" 255"
onchange =" window.location.href = forms [3] .elements [0] .value" />
< / td>
< / table>
< / form>

它适用于IE 6 SP2,但不适用于Firefox 1.6或Opera 8.0。 Opera没有做任何事情,Firefox给了我一个C不是注册协议的错误。有人可能会告诉我为什么这不起作用,以及如何解决它?


需要使用已知的协议或伪协议(http:,ftp:,mailto :)。

在这种情况下,请使用file:

window.location.href =''file:///''+ forms [3] .elements [0] .value

TIA,
Ian
-
http://www.bookstacks.org/




希望能帮到你。



Hope that does it for you.


Ian Rastall写道:
Ian Rastall wrote:
我在 http://www.sundry上有一个小搜索页面.ws / search.html
我想添加一个部分,允许我在我的
计算机上打开文件,而不必转到文件>打开。这样只是稍微容易一点。
I''ve got a small search page at http://www.sundry.ws/search.html and
I would like to add a section that allows me to open files on my
computer, instead of having to go to File > Open. It''s just slightly
easier that way.




你必须在每个浏览器中打开一个相同的文件并查看

他们作为网址提供的内容(位置栏)


然后用<输入文件

- >执行相同操作onchange =" alert(this.value)"


根据每个浏览器比较并制作JS以进行更正


即在我的Mac上输入给出的url是:

file://hard_drive/folder/file.htm



file:/// hard_drive / folder /file.htm



hard_drive / folder / file.htm

和rig.h url in location.href

将是:file://hard_drive/folder/file.htm

-

Stephane Moriaux et son [moins] vieux Mac



you have to open a same file in each browser and to see
what they give as url (location bar)

then do the same with <input file
-> onchange="alert(this.value)"

compare and make JS for corrections according to each browser

i.e. on my Mac url given by input is :
file://hard_drive/folder/file.htm
or
file:///hard_drive/folder/file.htm
or
hard_drive/folder/file.htm

and rigth url in location.href
would be : file://hard_drive/folder/file.htm
--
Stephane Moriaux et son [moins] vieux Mac


2005年7月27日19:26:07 -0700,Christopher J. Hahn写道:
On 27 Jul 2005 19:26:07 -0700, Christopher J. Hahn wrote:
在这种情况下,使用文件:
window.location.href =''file:///''+ forms [3] .elements [0] .value
In this case, use file:
window.location.href = ''file:///'' + forms[3].elements[0].value




谢谢,克里斯托弗。它现在可以在Firefox和IE中使用,但仍然不是Opera上的
。那可能现在没问题。 (不是我说了

上一句。):-)


Ian

-
http://www.bookstacks.org/

这篇关于允许客户端在自己的系统上打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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