JavaScript 判断文件是否存在
1. 客户端 //主要针对本地IE浏览器访问
<script
language="javascript">
function FileExist()
{
var sfso=new
ActiveXObject("Scripting.FileSystemObject");
var fPath="[The path of the
file]";
if(sfso.FileExists(fPath))
{
alert("Exist");
}
else
{
alert("Doesn't
exist");
}
}
</script>
2.
服务器端//远程浏览器访问和本地Firefox访问
<script
language="javascript">
function FileExist()
{
var xmlhttp=new
ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",FileURL,false);
xmlhttp.send();
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
alert("Exist");
else if(xmlhttp.status==404) alert("Doesn't
exist");
else alert("Don't know");
}
}
</script>
或者
<script language="JavaScript">
function fileExists(file)
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
if(xmlhttp.overrideMimeType)
{
xmlhttp.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject)
{
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
 
相关文档:
JavaScript进行GET和POST请求
Web上最常见的请求就是GET请求.每次在浏览器中输入URL并打开也米纳市,就是在向服务器发送一个GET请求.
GET请求:
GET请求的参数使用问号追加到URL的结尾,后米纳给这用&好连接起来的名称/值.例如:
http://www.somewhere.com/page.php?name1=value1&name2=value2&name3=value3
......
原文出处: http://www.dnew.cn/post/196.htm
先看下下面几种写法
1.function f(x){return x*x;};f(x);
2.(function(x){return x*x;})(x);
3.(function(x){return x*x;}(x));
第一种我们应该都很熟悉了,这是我们经常使用的写法。第二第三种都是匿名函数的写法。
------------------------------------------------ ......
一段JavaScript脚本程序,负责关闭窗口,如果网页不是通过脚本程序打开的(window.open()),调用window.close()脚本关闭窗口前,必须先将window.opener对象置为null,否则浏览器(IE7、IE8)会弹出一个确定关闭的对话框。
<script language="javaScript">
function closeWindow()
{
window.opener = null;
w ......
关于
JavaScript
正则表达对象的使用,其参考手册介绍如下:
语法 1
re = /
pattern
/
[flags
]
语法 2
re = new RegExp("
pattern
",
["
flags
"
])
参数
re
必选项。将要赋值为正则表达式模式的变量名。
Pattern
必选项。要使用的正则表达式模式。如果使用语法 1
,用 &q ......