如何使用js来确定文件是否存在? [英] How to use js to figure out if a file exists?

查看:105
本文介绍了如何使用js来确定文件是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个HTML JavaScript应用程序来动态更新由我们的报表服务器生成的报表。报告采用HTML格式。有空页时会出现问题。我收到错误404,我们都知道该页面不存在。我正在尝试编写代码来跳过不存在的页面。任何帮助,将不胜感激。这都是我们网络内部的,所以Active X一直打开都没关系。


请帮助!!!!!!!!!!


下面是我的代码...

I am writing an HTML JavaScript app to dynamically update reports that have been generated by our report server. The reports are in HTML. The problem comes when there are empty pages. I get an error 404, which we all know that the page doesn''t exist. I am trying to write the code to skip the pages that don''t exist. Any help would be appreciated. This is all internal to our network, so Active X all the way open is ok.

PLEASE HELP!!!!!!!!!!

Below is my code...

展开 | 选择 | Wrap | 行号

推荐答案

不确定ActiveX有什么库存,但在JavaScript中你可以发出一个AJAX HEAD请求(到服务器),它只返回文件响应头(保持404状态)。
not sure what ActiveX has in stock, but in JavaScript you can make an AJAX HEAD request (to the server), which only returns the file response headers (which hold the 404 status).


是我可以放在第一篇文章中提供的代码中。你能帮忙吗?
Is that something I can put in my code that was provided on the first post. Can you help?


Scripting.FileSystemObject对象有一个FileExists方法。
The Scripting.FileSystemObject object has a FileExists method.


这篇关于如何使用js来确定文件是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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