tags:

views:

24

answers:

1

Hi all,

I have the following code which i am using document.location.search in it.. I want to replace the ? with an &.. How i can do that please?

<script language="javascript">
        document.write("<a href='http://www.gfi.com/downloads/downloads.aspx?pid=fax&amp;lid=en" + document.location.search + "'><img src='http://images.gfi.com/download-imagery/button-download.png' border='0'></a>");
            </script>
+1  A: 
(document.location.search).replace("?","&");

so:

document.write("<a href='http://www.gfi.com/downloads/downloads.aspx?pid=fax&amp;lid=en" + (document.location.search).replace("?","&") + "'><img src='http://images.gfi.com/download-imagery/button-download.png' border='0'></a>");
seengee
why the brackets?
Alexander Gyoshev
just to highlight the separation between the two elements in the code so its easier for the OP to see whats happening
seengee