您的位置:程序门 -> web 开发 -> asp



关于jsript语法--求助


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于jsript语法--求助[已结贴,结贴人:slight1974]
发表于:2007-01-14 01:26:55 楼主
请教 <script>
function   fnhide(otohide){
window.settimeout( "fnhide2( "   +   otohide.id   +   ") ",   3000);
}
function   fnhide2(sid){
var   o   =   eval(sid);
o.style.display= "none ";
}
</script>
<input   type=button   value= "count   down "
id= "ohidebutton "   onclick= "fnhide(this) ">

这个fnhide2( "   +   otohide.id   +   ")为什么不能直接写成fnhide2(   otohide.id   )?
下面是另一个问题
    <script>
var   g_otohide   =   null;
function   fnhide(otohide){
g_otohide   =   otohide;
window.settimeout(fnhide2,   3000);
}
function   fnhide2(sid){
if   (g_otohide)   {
g_otohide.style.display= "none ";
}
}
</script>
<input   type=button   value= "now   you   see   me   ... "   id= "ohidebutton "
onclick= "fnhide(this) ">
这个是调用的id的?不明白,我看是调用的 <input> 这个标签的,可是说明说是调用了id这个指针.
发表于:2007-01-14 09:18:511楼 得分:5
第一个:
<script   type= "text/javascript "   language= "javascript ">
<!--
function   fnhide(otohide){
settimeout(function(){fnhide2(otohide.id);},100);
}
function   fnhide2(sid){
document.getelementbyid(sid).style.display= "none ";
}
//-->
</script>

<input   type=button   value= "count   down "   id= "ohidebutton "   onclick= "fnhide(this) ">
发表于:2007-01-14 09:25:072楼 得分:0
第二个是用的全局变量   把对象附给g_otohide   ,   没有用到对象的id

完整的这样写你好理解

if   (g_otohide!=null)   {
document.getelementbyid(g_otohide.id).style.display= "none ";
}
发表于:2007-01-14 10:31:133楼 得分:0
黑马,你好.第一个:function(){fnhide2(otohide.id)与fnhide2( "   +   otohide.id   +   ")等同吗?

为什么啊?主要就是不明白( "   +   otohide.id   +   ")这种写法代表什么意思?

第二个:既然没有用到用到 <id> 标签.就等同于 <input   style= "   diaplay:none "   type= "botton "  

value= "count   down "   id= "ohidebutton "   onclick= " "fnhide(this) ">

那body.input.style与body.input.id.style有什么不同啊,

谢谢.在线等,
发表于:2007-01-14 10:39:294楼 得分:0
补充:比如第一个用的是

g_otohide.style.display= "none ";

而g-otohide   是对 <id> 的引用

第二个g_otohide.style.display= "none ";是对 <input> 作用域这个标签的引用,想知道他们有什么区别,为什么第二个写成g_otohide.id.style.display= "none ";   就出错误了
发表于:2007-01-14 10:51:515楼 得分:0
你打破沙锅问到底的精神值得褒奖,但俺地文字工夫不好,理论知识也很浅薄,不好跟你描述,知其然就行了!呵呵
发表于:2007-01-14 10:53:416楼 得分:0
不好 意思啊!不搞明白用的不顺手,你给俺讲讲,我就结贴啊
发表于:2007-01-14 12:01:377楼 得分:0
不好意思,没有回,给3分了
发表于:2007-01-14 12:02:038楼 得分:0
怎么没有给上?


快速检索

最新资讯
热门点击