how do i find what's going wrong with my code
<p>I have this function for my sql javascript</p>

<pre><code>PATH="http://localhost/dhodia/";    
try{
                var tags=url.replace(PATH,"");
                var spl=tags.split("/");
                if(spl[0]=="i"){
                    if(spl.length&gt;=2 &amp;&amp; spl[1]=="hdd"){

                    }
                    addtoopen($("#"+spl[1]+"opn").attr("jso"));
                    menu_action(spl[1],url)   
                }
            }catch(err){
                var  txt="There was an error on this page.\n\n";
                txt+="Error description: " + err.message + "\n\n";
                txt+="Click OK to continue.\n\n";
                alert(txt);
            }
</code></pre>

<p>i found there is problem at replace statement
if i use url  as <strong>"http://localhost/dhodia/i/hdd"</strong> it will do replace 
but if i use <strong>"http://localhost/dhodia/i/hdd/tarun"</strong> it is not doing replace</p>

<p>i want to track why it is not taking replace at this line </p>

<p><strong>EDIT</strong></p>

<p>I am using this in function as shown below</p>

<pre><code>function hstppst(url){
    config.pre=url;
    if(url==PATH || url==PATH+"i/dashboard"){
        $E("#"+current.open).hide();
        unfixbox()
        $E("#dashboard").show();
        addtoopen(dsjsn);
        document.title="My DashBoard";
        current.open="dashboard";
    }else{
        var tags=url.replace(PATH,"");
        var spl=tags.split("/");
        if(spl[0]=="i"){
            if(spl.length&gt;=2 &amp;&amp; spl[1]=="hdd"){

            }
            addtoopen($("#"+spl[1]+"opn").attr("jso"));
            menu_action(spl[1],url)   
        }



    }     
}
</code></pre>

<p>and this function call when  <code>window.onpopstate</code> changes</p>

<p>in onpopstate i pass url to this function</p>

<p>problem is that code is not executing after <code>var tags=url.replace(PATH,"");</code> and because i am using this function in onpopstate function if any error occurs poage refreshed and i am track what is error i am getting.</p>
