<html>
<head>
 <SCRIPT LANGUAGE = " JavaScript ">
   Object.prototype.toString = function ()  { return  'myToString'}   
var  o = new  Object();  
o.name = 'zkj';  
o.age = 25 ;  
o.desc = function ()  { return  '姓名:' + this .name + ',年龄:' + this .age}  
for ( var  key  in  o)  {  
   alert(key + ':' + o[key] + ' type:' + typeof (o[key]));  
if ( typeof (o[key]) == ' function ')  {  
 alert('执行方法key:' + (o[key])());  
}   
}   
   alert(o); 
   alert( new  Date()); 
</SCRIPT>   
</head>
<body>
</body>
</html>请大虾帮忙改下!

解决方案 »

  1.   

    typeof (o[key]) == ' function '//单引号里两端有空格,去掉就可以了
      

  2.   

    <html>
    <head>
     <SCRIPT LANGUAGE = "JavaScript">
           Object.prototype.toString = function ()  { return  'myToString'}   
                var  o = new  Object();  
                o.name = 'zkj';  
                o.age = 25 ;  
                o.desc = function ()  { return  '姓名:' + this .name + ',年龄:' + this .age}  
                for ( var  key  in  o)  {  
                   alert(key + ':' + o[key] + ' type:' + typeof (o[key]));  
                    if ( typeof (o[key]) == 'function')  {  
                         alert('执行方法key:' + (o[key])());  
                    }   
                }   
           alert(o); 
           alert( new  Date()); 
    </SCRIPT>   
    </head>
    <body>
    </body>
    </html>这个已经可以了
      

  3.   

    L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
      <script type="text/javascript">
      <!--
    Object.prototype.toString = function() {
    return  'myToString';
    };
    var o = new Object();  
    o.name = 'zkj';  
    o.age = 25 ;  
    o.desc = function() {
    return  '姓名:' + this .name + ',年龄:' + this .age;
    };  
    for (var key in o) {  
    alert(key + ':' + o[key] + ' type:' + typeof (o[key]));  
    if ( typeof(o[key]) == 'function') {
    alert('执行方法key:' + (o[key])());
    }   
    }   
    alert(o); 
    alert(new Date());
      //-->
      </script>
     </body>
    </html>
      

  4.   

    <SCRIPT LANGUAGE = " JavaScript ">
    javascript 这儿也不能有空格