<script>Additional JavaScript String Objects
var content = encodeURI(window.location);
document.write(content + '<br >');
document.write(content.charAt(0) + '<br />'); //returns the character at the number position http://www.blogger.com/img/blank.gif
document.write(content.length + '<br />'); //string length
document.write(content.indexOf('a') + '<br />'); //position of first occurence
document.write(content.lastIndexOf('a') + '<br />'); //positions of last occurence
document.write(content.substring(5,10) + '<br />'); //substring(start,end)
document.write(content.substr(2,3) + '<br />'); // substr(start, length from start)
// Try not to confuse substr and substring the completely different
</script>
Monday, October 3, 2011
Javascript String Manupulation Examples
Below are javascript functions to manipulate the URL and most common used string manipulators.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment