如何在javascript中定义静态变量? [英] How to define a static variable in javascript.?
本文介绍了如何在javascript中定义静态变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在所有网页中都使用了单个javascript代码.我使用了一个计数器变量来计算从相应页面打开的链接数.当第一页称为js代码时,将声明和定义变量.如果我从头开始打开5个链接,则计数器的值将为5.因此,如果我从已打开的链接中打开一个链接,则计数器的值应增加到6,依此类推,但在我的情况下,它的值将再次定义并从零开始.
请任何人让我解决..
谢谢..
Hi i am using single javascript code in my all web pages. I used a counter variable to count the number of links opened from the respected page. when the first page called js code the variables get declared and defined. if i opened 5 links from first, the value of the counter will be 5. So if i open a link from the already opened link, the counter value should increment to 6 and so on but in my case its again defined and begins with zero.
pls anyone let me a solution..
Thank you..
推荐答案
看看: ^ ]
希望对您有所帮助.
have a look at :http://www.deluxeblogtips.com/2010/04/missing-way-to-create-function-static.html[^]
hope this helps.
这篇关于如何在javascript中定义静态变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文