javascript
2010-10-18 25 views 0 likes 
0

我有下面的代碼,我在它使用document.location.search ..我想要替換?與& ..我該怎麼做,請嗎?替換? from 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
(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>"); 
+0

爲什麼括號? – 2010-10-18 08:48:32

+0

只是爲了突出代碼中兩個元素之間的分隔,以便OP更容易看到發生了什麼 – robjmills 2010-10-18 09:06:14

相關問題