Split is not working in javascript

Hi Friends,
I tried to use Split javascript function in one of my function to extract the string, but it was not working as expected and was throwing ans javascript error.
I found good solution for this.

JavaScript Code:

<script>
var url = window.location.href;
url_parts = url.split('/');
<script>

The code was not working and was throwing javascript error for split is not a function.
Then I changes the code as follows which works fine for me.

JavaScript Code:

<script>
var url = window.location.href;
var url_parts;
url = url.toString();
url_parts = url.split('/');
<script>

Happy Coding !!



Leave a Reply

You must be logged in to post a comment.