本人写的一个转换函数,用onClick事件替换<a href></a>,
示例
替换成
附录
在下面的例子中,我们将演示用encodeURIComponent()来编译URIs:
输出结果为:
function redirectURL(url,para) {
window.location.href=url+encodeURIComponent(para);
}示例
<A class="pl" href="/product/product.asp?id=<%Response.Write(rs("PartNo"))%>">替换成
<A class="pl" onClick="javascript:redirectURL('/product/product.asp?id=', '<%Response.Write(rs("PartNo"))%>')">附录
在下面的例子中,我们将演示用encodeURIComponent()来编译URIs:
<script type="text/javascript">
document.write(encodeURIComponent("http://www.test.com"))
document.write("<br />")
document.write(encodeURIComponent("http://www.test.com/p 1/"))
document.write("<br />")
document.write(encodeURIComponent(",/?:@&=+$#"))
</script>输出结果为:
http%3A%2F%2Fwww.test.com
http%3A%2F%2Fwww.test.com%2Fp%201%2F
%2C%2F%3F%3A%40%26%3D%2B%24%23
本文介绍了一个使用JavaScript编写的函数,该函数可以将链接参数进行URL编码,并通过onClick事件触发页面跳转。文章还提供了使用encodeURIComponent()函数进行URI编码的具体示例。
1114

被折叠的 条评论
为什么被折叠?



