Javascript: Find index of slash (/) in a string
<p>I don't know much about javascript (only done JAVA) but that havent keept me from doing a hack on some javascript code I found (from Google Bookmarks).</p>

<p>Here is my case: I'm creating a bookmark in my browser that contains a javascript instead of a URL link. When I press the bookmark I want it to open a new window with the same url but with some extra info.
So say Im on <a href="https://www.abcde.com/KnowYourABC" rel="nofollow">https://www.abcde.com/KnowYourABC</a> and I press the bookmark, then it should open a window with the link: <a href="https://www.abcde.com.DoYou/KnowYourABC" rel="nofollow">https://www.abcde.com.DoYou/KnowYourABC</a> - so ".DoYou" have been inserted just before the 3th "/"</p>

<p>I have the following script:</p>

<pre><code>javascript:(function(){
    var a=window, b=document, c=encodeURIComponent,
    url = b.location,
    d = a.open(url, "bkmk_popup", "left="+
    ((a.screenX||a.screenLeft)+50)+",top="+
    ((a.screenY||a.screenTop)+50)+
    ",height=600px, width=1200px, resizable=1, alwaysRaised=1");
    a.setTimeout(function(){d.focus()},300)
})();
</code></pre>

<p>So far it opens a window with the same url. But I can't seem to split the url at the 3th "/". Have tried to get the index of the backslash in order to split the url and insert ".DoYou"</p>

<pre><code> i = url.indexOf("//",9)
</code></pre>

<p>but then the window will not open. Please help me out!</p>

<p><strong>SOLUTION</strong></p>

<pre><code>javascript:( function(){ 
    var a=window;
    b=document;
    c=encodeURIComponent; 
    url = b.location; 
    var parts = window.location.href.split("/");
    parts[2] += ".DoYou";
    var newurl = parts.join("/");
    a.open(newurl, "bkmk_popup","left="+((a.screenX||a.screenLeft)+50)+",top="+((a.screenY||a.screenTop)+50)+",height=600px,width=1200px,resizable=1,alwaysRaised=1"); a.setTimeout(function(){d.focus()},300);
})();
</code></pre>
