title: Get baseurl in javascript file-codeigniter
body: <p>I need   to get the base url of the project in a javascript  function.
  my code is</p>
  
  <pre><code>function add_more()
  {
      var numrows=parseInt(document.frm_add_announcement.cnnumrows.value)+1;
      var strinner="";
      var ni = document.getElementById('content');
      var newdiv = document.createElement('div');
      var divIdName = 'my'+numrows+'Div1';
      newdiv.setAttribute('id',divIdName);
      document.frm_add_announcement.cnnumrows.value=numrows;
      //alert("asdAS");
  
        strinner="&lt;div class='row'&gt; &lt;div class='col-md-3'&gt;&lt;div class='form-group'&gt;&lt;input type='text' id='imgcaption"+numrows+"' name='imgcaption"+numrows+"' placeholder='Attachment caption'  class='form-control'/&gt;&lt;/div&gt; &lt;/div&gt;&lt;div class='col-md-2'&gt;&lt;div class='form-group'&gt;&lt;input type='file' id='document"+numrows+"' name='document"+numrows+"' onclick='disableurl("+numrows+")' /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class='col-md-1'&gt;&lt;label for=''&gt;&lt;/label&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;img src='../../../images/close3.png' title='Click to remove File'  id='clear_multiple"+numrows+"' height='25px'  style='cursor:pointer' onclick='remove("+numrows+")'/&gt;&lt;/div&gt;&lt;div class='col-md-3'&gt;&lt;div class='form-group'&gt;&lt;input type='text'  id='url"+numrows+"' name='url"+numrows+"' placeholder='Attachment URL' onkeyup='disablefile("+numrows+")'   class='form-control'/&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class='col-md-3'&gt;&lt;div class='form-group'&gt;&lt;select class='form-control' id='target_type"+numrows+"' name='target_type"+numrows+"'  &gt;&lt;option&gt;-Choose-&lt;/option&gt;&lt;option&gt;Same tab&lt;/option&gt;&lt;option&gt;New tab&lt;/option&gt;&lt;/select&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;";
  
   //$(".remove-btn").live('click',function() {
                  //$(this).parent().remove();
              //});
  
      newdiv.innerHTML=strinner;
      ni.appendChild(newdiv);
  
  }
  </code></pre>
  
  <p>need to get the <code>baseurl</code> in the <code>src=""</code> of the image in <code>strinner</code>.</p>