我有一个在表单上放置输入按钮的程序。当用户单击按钮时,onclick 属性使用 location.href 将其定向到链接。
elementButton_1.setAttribute("onclick", "self.location.href='http://google.com'; return false");
我正在尝试将链接存储在数组中。如何将数组插入位置调用?
例子:
locationArray = new Array();
locationArray[0] = "http://google.com";
elementButton_1.setAttribute("onclick", "self.location.href=locationArray[0]; return false");