我有以下代码,我在其中使用document.location.search ..我想替换?和& ..我怎么能这样做?
<script language="javascript">
document.write("<a href='http://www.gfi.com/downloads/downloads.aspx?pid=fax&lid=en" + document.location.search + "'><img src='http://images.gfi.com/download-imagery/button-download.png' border='0'></a>");
</script>
答案 0 :(得分:1)
(document.location.search).replace("?","&");
这样:
document.write("<a href='http://www.gfi.com/downloads/downloads.aspx?pid=fax&lid=en" + (document.location.search).replace("?","&") + "'><img src='http://images.gfi.com/download-imagery/button-download.png' border='0'></a>");