首页 新闻 会员 周边 捐助

js如何获得全局变量的值

0
悬赏园豆:5 [已关闭问题]
<pre><span style="color: #000000;"> </span><span style="color: #000000;">&lt;!</span><span style="color: #000000;">DOCTYPE html PUBLIC </span><span style="color: #000000;">"</span><span style="color: #000000;">-//W3C//DTD XHTML 1.0 Transitional//EN</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</span><span style="color: #000000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">html xmlns</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">http://www.w3.org/1999/xhtml</span><span style="color: #000000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">head</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">meta http</span><span style="color: #000000;">-</span><span style="color: #000000;">equiv</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">Content-Type</span><span style="color: #000000;">"</span><span style="color: #000000;"> content</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">text/html; charset=gb2312</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">/</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">title</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">无标题文档</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">/</span><span style="color: #000000;">title&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">script type</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">text/javascript</span><span style="color: #000000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #0000ff;">var</span><span style="color: #000000;"> ddd; </span><span style="color: #0000ff;">function</span><span style="color: #000000;"> see(num) { ddd</span><span style="color: #000000;">=</span><span style="color: #000000;">num; } alert(ddd); </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">/</span><span style="color: #000000;">script&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">/</span><span style="color: #000000;">head&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">body</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">a href</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">#</span><span style="color: #000000;">"</span><span style="color: #000000;"> onclick</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">see(num)</span><span style="color: #000000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">看一下效果</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">/</span><span style="color: #000000;">a&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">/</span><span style="color: #000000;">body&gt;</span><span style="color: #000000;"> </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">/</span><span style="color: #000000;">html&gt;</span><span style="color: #000000;"> </span></pre>
qiuqingpo的主页 qiuqingpo | 初学一级 | 园豆:165
提问于:2009-08-15 15:47
< >
分享
其他回答(2)
0

你的写法没有错啊,有什么疑问呢?

Gray Zhang | 园豆:17610 (专家六级) | 2009-08-15 21:03
0

num,是个局部变量,肯定要报错的,而且你这个方法里,连个alert都没有,能知道ddd吗

chenleinet | 园豆:270 (菜鸟二级) | 2009-08-16 00:03
0
onclick="see(num)" 这肯定会报错的,不知道楼主想做什么
Chihom | 园豆:150 (初学一级) | 2009-08-16 08:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册