除了IE之外的其他浏览器的ActiveX对象的替代? [英] Alternative for the ActiveX object for the other browsers excluding IE?

查看:3562
本文介绍了除了IE之外的其他浏览器的ActiveX对象的替代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我,因为我被困在创建一个文件(临时)与本地磁盘扩展(说.csv),我尝试使用ActiveX对象,但它只工作正常在互联网浏览器,得到一个错误,当我尝试与其他浏览器。通过googling我知道ActiveX只在IE中工作,所以当它在不同的浏览器尝试时产生错误。

Can anyone help me as i am stuck in creating a file(temporary) with extension(say .csv) in the local disk, i tried using ActiveX object but it works fine only in internet explorer,got a error when i tried with other browsers. By googling i got to know ActiveX works only in IE so it produces error when its tried in different browser.

    var fso, f1;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f1 = fso.GetFile("c:\\test.txt");
    alert(f1);

任何人都可以向我推荐一个非常有用的替代品。

Can anyone suggest me with the alternative which can be very useful to.

推荐答案

其他帖子涵盖了有关使用Html 5存储到本地机器的所有信息,所以我不会进一步的细节,但这只是去工作在Html 5兼容的浏览器(虽然大多数浏览器是Html 5兼容,现在,我不知道你的项目要求)。

The other posts cover all the information about storing to the local machine using Html 5 so I won't go into any more detail about that but this is only going to work on Html 5 compatible browsers (although most browsers are Html 5 compatible now, I don't know your project requirements).

另一个选择是创建/使用服务器端代码(ASP.NET,PHP等)保存文件,然后提供一个链接到用户,以便他们可以下载文件。您仍然可以将其另存为.csv文件,以便用户在下载后可以在Excel中打开它。

Another alternative would be to create / save the file using server side code (ASP.NET, PHP etc) and then provide a link to the user so they can download the file. You can still save this as a .csv file so that the user can open it in Excel after they have downloaded it.

编辑:

我会做的是更改您的Web服务,以便它将文件保存到光盘(更多信息:此处)。然后,不是从Web服务返回文件,而是返回Url以进行下载。然后,您可以使用JS将用户重定向到该链接。

What I would do is change your web service so that it saves the file to disc (more info: here). Then instead of returning the file from the web service, return the Url to download it instead. You can then redirect the user to that link using JS.

这篇关于除了IE之外的其他浏览器的ActiveX对象的替代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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