substr not working in IE browser - issue solved

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>

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.