JavaScript获取当前文件全路径、当前目录、当前文件名
//获取当前文件全路径
<script language="javascript">
alert(window.location.href);
alert(window.location);
alert(location.href);
alert(parent.location.href);
alert(top.location.href);
alert(document.location.href);
alert(document.URL);
</script>
//获取当前目录方法
<script type="text/javascript">
//方法一
var str = location.href;
var arr = str.split("/");
delete arr[arr.length-1];
var dir = arr.join("/");
alert(dir);
//方法二
alert(location.href.substring(0,location.href.lastIndexOf('/')));
</script>
//获取当前文件名
<script language=javascript>
var filename=location.href;
filename=filename.substr(filename.lastIndexOf('/')+1);
alert(filename);
</script> ......
全部文字
全部图文
相关文档:
<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)"> ......
js的Function对象在调用过程中具有一个arguoments属性,它是由脚本解释器创建的,这也是创建arguments对象唯一途径。arguments对象可以看做是一个Array对象,它具有length属性,可以通过序号访问每一个参数。而且,通过arguments 的callee属性可以获取对只在执行的Function对象的引用,如下 ......
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function setCookie(name, value, expires, path, domain, secure)
{
var liveDate = new Date();
expires = l ......
原文出处: 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));
第一种我们应该都很熟悉了,这是我们经常使用的写法。第二第三种都是匿名函数的写法。
------------------------------------------------ ......
1. 客户端 //主要针对本地IE浏览器访问
<script
language="javascript">
function FileExist()
{
var sfso=new
ActiveXObject("Scripting.FileSystemObject");
var fPath="[The path of the
file]";
if(sfso.FileExists(fP ......