尝试将i
变量传递给必须更改值的test
函数:
<HTML>
<HEAD>
<TITLE> Welcome to my site</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JAVASCRIPT">
var atl = new ActiveXObject("ATL.Object.1");
var i =6;
atl.test(i);
document.write(i);
</SCRIPT>
</BODY>
但在输出中我还有6
。如何通过引用传递值?
答案 0 :(得分:0)
在Javascript上通过引用传递不存在。你可以使用一个对象来传递,它就像通过引用传递一样。
例如:
var atl = new ActiveXObject("ATL.Object.1");
var i = { value: 6};
//if ActiveXObject does not work with your Object, than you need to make an adapter or store the value back to i
atl.test(i);
document.write(i.value);