更换?来自document.location.search

时间:2010-10-18 08:40:02

标签: javascript

我有以下代码,我在其中使用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>

1 个答案:

答案 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>");