substr not working in IE browser – issue solved

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>

Add a Comment

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