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)
 
相关文档:
a href="javascript:if(confirm(
悬赏分:0 - 解决时间:2008-9-25 13:58
a href="javascript:if(confirm('http://hunter.51rc.com/ \n\n文件并未依 Teleport Pro 取回,因为 它的域或路径超过开始网址中设置的范围。 \n\n你要从服务器上打开它吗?'))window.location='http://hunter.51rc.com/'" tppabs="http://h ......
我们都知道java、c#、vb等语言都有sleep暂停的函数,而JavaScript脚本没有类似的功能。
下面就是我的实现的方法:
<mce:script type="text/javascript"><!--
function test()
{
var s="javascript--暂停函数";
setTimeout(
function(){
eval(sleep(test)); //执行return之后的代码,也就是&ldq ......
<input type=button value=刷新 onclick="window.location.reload()">
<input type=button value=前进 onclick="window.history.go(1)">
<input type=button value=后退 onclick="window.history.go(-1)"> ......
【!声明:此程序只供研究使用,如用做不正当用途后果自负】
100秒内蓝屏死机的Javascript脚本源代码
引自:http://www.webdeveloping.cn/blog/?action=show&id=78
<html>
<head>
<script LANGUAGE="javascript">
function leave() {
window.open(file:///c:/nul/nul,,toolbar=no,menub ......
JavaScript 事件方法
http://www.webdeveloping.cn/blog/?action=show&id=207
事件源对象
event.srcElement.tagName
event.srcElement.type
捕获释放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
事件按键
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
事件返回值
......