怎样把javascript中的值传递给a标签中的href属性

function number(result) {
var reg = /\/\d+(?=\.)/; /*regular expression to get the filename*/
var reg2 = /\d+/;
var filename = document.URL;
var filename = reg.exec(filename); //exective the reuglar expression
result = reg2.exec(filename); //get the file name without filetype
//alert(parseInt(result) + 1 + ".htm");
}

我利用一个javascript函数获取当前网页名称,再经过一些变换之后,放入到html的连接中。比如上面的代码,我result的结果是1,那么我想在页面中添加一个html连接,打开2.htm,请问怎么做。

<a href="">aaa</a>

标签a的onclick方法角度出发解决问题

方法最后修改a标签链接,代码大概如下
document.getElementByTags('a')[0].href = '2.htm';
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-11-04
设置a的id,然后在javascript中添加代码a.href=parseInt(result)+ ".htm" 就行了。
第2个回答  2010-10-28
加我百度好友,ideaer团队为你解决
第3个回答  2010-11-03
<a id=
相似回答
大家正在搜