If you want it to be dynamic, so that the value of the variable at the time of the click is used, do the following:
(如果您希望它是动态的,那么使用单击时变量的值,请执行以下操作:)
<script language="javascript" type="text/javascript">
var scrt_var = 10;
</script>
<a href="2.html" onclick="location.href=this.href+'?key='+scrt_var;return false;">Link</a>
Of course, that's the quick and dirty solution.
(当然,这是快速而肮脏的解决方案。)
You should really have a script that after DOM load adds an onclick handler to all relevant <a>
elements.(你应该有一个脚本,在DOM加载后为所有相关的<a>
元素添加一个onclick处理程序。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…