onClick = "location.replace Problem

Discussion in 'JavaScript' started by meannn, Jun 19, 2009.

  1. #1
    Hello, I have a script that like;

    <script language="JavaScript">
    document.write('<input border=0 type=button value=\'\' ');
    document.write(' onClick = "location.replace(');
    document.write(' document.stats.site.value + \'/\');"');
    document.write(' value="Search">');
    document.write('</input>');
    </script>

    Works nice. It directs the user to the location that written in the text input. I mean user write a site and the script directs the user to mysite.com/stat/userwrittensite.com/

    The problem is,

    If the user do the same action after, it directs
    to mysite.com/stat/userwrittensite.com/userwrittensite2.com/

    How can I fix it ? Thanks...
     
    meannn, Jun 19, 2009 IP