html中href如何引用变量?

http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title)+' 我想访问这个网址,但是title后单引号里的无法运算,我想让+ +之间运算出来再赋值给title,怎么解决??

这个用js来实现比较好,直接修改a标签的href属性
例如:
<a href="#" id="aa">123</a>
-----------------------------------------
var newHref = 你要的值
$('#aa').attr("href",newHref )
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-05-04
location.href = ''<%=encodeURIComponent(document.title)%>
第2个回答  2011-05-04
<%= encodeURIComponent(document.title) %>追问

朋友,我在运行时出现:当前上下文中不存在名称“encodeURIComponent”错误,这代码用不用单引号?

追答

你这个方法是什么方法
是后台的还是 前台

本回答被提问者采纳
第3个回答  2011-05-04
location.href = ''+encodeURIComponent(document.title);

相关了解……

你可能感兴趣的内容

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