substr() javascript method extracts characters from a string. Here is working example for substr function. solved issue, substr not working in IE browser

substr not working in IE browser – issue solved

substr not working in IE browser - issue solved

substr not working in IE browser – issue solved




var str="Hello world!";
document.write(str.substr(3)+"<br />");
document.write(str.substr(3,4));

</script>

This function works with following browser.

  • Firefox
  • Safari
  • Opera
  • google chrome

There is issue with IE browser. Do not use the substr javascript method – this function is not working in IE browser.

You need to use the substring() method. This is similar to substr. You can achieve your work by using this method.

Following is the working example of substring method.


<script type="text/javascript">

 var str="Hello world!";
 document.write(str.substring(3)+"<br />");
 document.write(str.substring(3,7));

 </script>

Written by Purab Kharat

I Purab am from India, Pune. I am WordPress and Drupal Architect and consultant. I worked on many technologies like Ruby on Rails, Flex, PHP, jQuery etc... Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA.I contributed to many wordpress plugins and Drupal Modules. I contributed to Drupal core also.Connect to purab on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>