Probá así:
 Código PHP:
    <script>
cad='ratapodridainmundapodrida'
s='podrida'
String.prototype.substr_count = function() 
{
  var search = arguments[0];
  var count = 0;
  var pos = this.indexOf(search);
  while ( pos != -1 ) {
     count++;
     pos = this.indexOf(search,pos+1);
  }
  return count;
}
alert(cad.substr_count(s))
</script>