还要能够支持这种
function abc()
{
this.name;
this.gender;
this.open=function()
{
alert(...));
}
}
function abc()
{
this.name;
this.gender;
this.open=function()
{
alert(...));
}
}
解决方案 »
- 求js模拟的滚动条
- 再问一个超难的问题.
- 谁能给写我一段能提交但不跳转的javascript代码?
- 这个轮播广告的代码在IE下可以,在火狐下就不行,为啥??
- 怎么样让div隐藏和显示?
- 当关闭窗口IE 的时候怎么记录用户退出的时间?怎么来触发这个事件?我的页面有FRAME。有Header,Footer,Body?
- JavaScript怎么取得当前form对象
- 求一段有关FRAME的JAVASCRIPT代码
- 请问csdn专家门诊窗口左边的树型目录是怎么做的!不要原代码,要思路!
- 在遍历一些dom元素,删除其中一个dom元素,但是报错underfind,然后便利的元素绑定的事件处理程序都没有效果了。怎么办
- javascript如何在服务器端建立一个文件?
- 这个问题是用Hidden解决的吗???????????????????????????
function abc(NAME){
this.name=NAME;
this.tellMe=function(){
alert(this.name);
}
}
var o=new abc("abc");
o.tellMe();
</script>
<!-- function abc()
{
this.name;
this.gender;
this.open=function()
{
alert(this.constructor.toString().replace(/^function\s(\w*)[\s\S]*$/,"$1"));
}
}
var n = new abc();
n.open();//-->
</script>你说的两种情况都可以这样来解决,但并不是完善的,因为只有此函数被实例化的时候,this关键字才指向本身,否则指向window/其它.对于直接函数调用,没想到好的办法,可以作为函数参数传进去.
这个不行,因为有时候我的函数是这么定义的
<script type="text/javascript">
<!-- abc=function()
{
this.name;
this.gender;
this.open=function()
{
alert(this.constructor.toString().replace(/^function\s(\w*)[\s\S]*$/,"$1"));
}
}
var n = new abc();
n.open();//-->
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>环球旅业</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/global.css">
<script language="javascript" src="/js0.11/$.js"></script>
</head>
<body>
<script>
function f1()
{
this.ff = function ff() //变通一下
{
var v = arguments.callee.toString();
alert(v.replace(/({(.|[^.])+})|(function)+|(\(\))|\s+/ig,""));
}
}
var f1 = new f1();
f1.ff();
</script>
</body>
</html>
函数里的私有属性是遍历不到的.