Javascript function working strangely during the first call in CHROME?
<p>HI all,</p>

<p>Below mentioned javascript code works fine in all browsers including chrome(from second call onwards). </p>

<pre><code>function call(val){
        url = window.location.href;
        indexnum = url.lastIndexOf("/");
        str = url.slice(indexnum+1);
        window.location.href = url.replace(str, "sample.php?src_q=") + val;
    }
</code></pre>

<p>I am calling this function on onclick of a link as below</p>

<pre><code>&lt;?php  echo "&lt;a href='#' onclick='javascript:call(\"$fieldvalue\");'&gt;$fieldvalue&lt;/a&gt;"  ?&gt;
</code></pre>

<p>Normal Behaviour : In all browser after clicking on the link new formed url is </p>

<p>url://localhost/mysite/sample.php?src_q=val</p>

<p>Strange Behaviour : When I click on the link for the first time in chrome value of variable <code>val</code> gets replaced by url and its value as follows</p>

<p><a href="http://localhost/mysite/sample.php?src_q=http://localhost/mysite/val" rel="nofollow">http://localhost/mysite/sample.php?src_q=http://localhost/mysite/val</a></p>

<p>This strange behaviour happens during the first click in chrome. From the second call onwards in the same tab, the value of variable <code>val</code> works fine and I get desired url.</p>

<p>I tried to google on it, but couldn't found any explanation. </p>

<p>Thanks in advance.</p>
