I’m assuming that you’re running this in a page that is being loaded off of 
your hard drive?

JavaScript generally does not have access to the file system for security 
reasons (Internet Explorer imposes more restrictions than others by default). 
Firefox’s behavior in this case is the exception rather than the rule.

-Nicholas

From: Discussion of JavaScript 
Sent: Sunday, December 05, 2010 8:30 AM
To: [email protected] 
Subject: Re: [JSMentors] How to check whether a file exists(locally!)?

BTW, I know in firefox I can use "try...catch" to implement what I want, but is 
it "good" solution? 
And I can do nothing in Chrome...


On Mon, Dec 6, 2010 at 12:21 AM, Yu-Hsuan Lai <[email protected]> wrote:

  I guess that XMLHttpRequest can work on this issue, but this code: 

  ---
  xmlHttp.open("GET", "01.swf", false);
  xmlHttp.send();
  return xmlHttp.status == 0;
  ---

  totally can't work in Chrome(though "01.swf" exactly exists, I get 
"ETWORK_ERR: XMLHttpRequest Exception 101").
  In Firefox, it works if "01.swf" exists. If not, I get "Access to restricted 
URI denied" code: "1012".

  I believe javascript can know whether a file exists, but how?

  -- 
  Lai, Yu-Hsuan




-- 
Lai, Yu-Hsuan



--------------------------------------------------------------------------------
_______________________________________________
JSMentors mailing list
[email protected]
http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com
_______________________________________________
JSMentors mailing list
[email protected]
http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com

Reply via email to