求 javascript innerhtml 中变量的写法

有一个串:
innerHTML = "<img src=expand.gif class=ec>"+"<A HREF='" + thisn.getAttribute("href") + "' TARGET=\"mainFrame\" " +">" +thisn.getAttribute("text") +"</a>" ;

这个串是在JAVASCRIPT 中用来 显示html 的一个链接.<a href gg.asp target="mainFrame">text</a>

我现在想在链接的后面添加个 参数来传递,最终生成 如:.<a href gg.asp?param=aa target="mainFrame">text</a>

我想加的量是: thisn.getAttribute("href") , 不知道应该怎样加.试了很多种都出错.各位帮我解决一下,

第1个回答  推荐于2016-09-19
innerHTML = "<img src=expand.gif class=ec>"+"<A HREF='" + thisn.getAttribute("href") + "?param=aa' TARGET=\"mainFrame\" " +">" +thisn.getAttribute("text") +"</a>" ;

不会的话 留言给我本回答被提问者采纳
第2个回答  2009-03-12
var a = "?param=aa";
innerHTML = "<img src=expand.gif class=ec>"+"<A HREF='" + thisn.getAttribute("href") + a + "' TARGET=\"mainFrame\" " +">" +thisn.getAttribute("text") +"</a>" ;
第3个回答  2009-03-12
你好:

前面的我不说了,说后面的
"<a href='"+ thisn.getAttribute("href") + "' target='mainFrame'>" + +thisn.getAttribute("text") +"</a>" ;

其实就是把里面一层的" 变成 ' 就可以了

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网