谁帮我详细解释以下JS语句执行的原理 window.c 这句有什么特别意义吗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 window.c = ... // 赋值语句;function(){...}() // 赋值语句的右侧表达式,这叫 匿名函数自调用,最后滴括号很重要!由于 function(){...}() 没有返回值,因此 alert(window.c) 仍为 undefined! 真滴没意义!去掉以后效果一样!javascript:alert(function(){document.getElementsByTagName("input")[0].value = "你看看我的长度有没有4个字符呢?"}()) 但是如果匿名函数有返回值滴话,那就有意义了,即为 window.c 赋值! 改了改,有返回值了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="" /> <script type="text/javascript"> <!--var i = 0; //--> </script> </head> <body> <input type="text" id="" size="100" /> <input type="text" id="" size="100" /> <input type="text" id="" size="100" /> <input type="text" id="" size="100" /> <input type="button" value="run" onclick="alert(window.c=function(){return document.getElementsByTagName('input')[i++].value = '你看看我的长度有没有'+i+'个字符呢?';}())" /> <input type="button" value="show window.c" onclick="alert(window.c)" /> </body></html> FLASH图片切换效果-如何实现动态链接数据库的代码 遇到null就无法运行下去,怎么解决? 引用 js做头文件 为什么下面的内容没有出来 网页键盘控制的问题 RPG游戏地图构成 谁有MzTreeView 2.0和应用实例给偶发一份,谢谢了!!!! 如何修改这个js让图片显示缩略图?????求教大神 急!再求动态效果 为什么他判断完用户名不为空且小于3位就可以顺利提交表单了? Extjs5.0 Chart问题 Body的ONLOAD可以调用2个变量吗 a标签如何在前台调用后台的代码
function(){...}() // 赋值语句的右侧表达式,这叫 匿名函数自调用,最后滴括号很重要!
由于 function(){...}() 没有返回值,
因此 alert(window.c) 仍为 undefined!
去掉以后效果一样!
javascript:alert(function(){document.getElementsByTagName("input")[0].value = "你看看我的长度有没有4个字符呢?"}()) 但是如果匿名函数有返回值滴话,那就有意义了,即为 window.c 赋值!
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="" />
<script type="text/javascript">
<!--
var i = 0;
//-->
</script>
</head> <body>
<input type="text" id="" size="100" />
<input type="text" id="" size="100" />
<input type="text" id="" size="100" />
<input type="text" id="" size="100" />
<input type="button" value="run" onclick="alert(window.c=function(){return document.getElementsByTagName('input')[i++].value = '你看看我的长度有没有'+i+'个字符呢?';}())" />
<input type="button" value="show window.c" onclick="alert(window.c)" />
</body>
</html>