Category: Javascript
How to Use Plain Old JavaScript File into Node.js as a Module
If you want to use your plain old JavaScript file into Node.js, you need to create a module which is nothing but a fancy wrapper around your JavaScript file and then you can use all the functions of your JavaScript object into Node.js. Environment Windows 7 (64 bit) Node.js 4.4.2 (64 bit) Path already contains…
Crash FreeTextBox using Javascript
Would you like to crash FreeTextBox? Here is the trick. Visit the page http://freetextbox.com/demos/Default.aspx Click on HTML view and copy/paste the following code. Press “Save” button. This will convert your code into Note that “a” is missing. Pretty interesting!!! hmmmmmm….Now again click on HTML view and copy/paste following code Now you will see error….. Hurray………
Be Careful When You Are Using Javascript parseInt() Function
First of all guess the result for the following JavaScript code. In JavaScript if the string starts with “0”, the string will be parsed as if it is octal number. (i.e. base 8) instead of decimal number(i.e. base 10). So if you are parsing a string containing integer value and fear about leading zeroes, always…
Cross Browser Javascript Code to Get/Set Caret Position in Textarea/Input Textbox
Note: In year 2024, this solution still works for textarea/input. Here is a working snippet of code to get and set the caret position in HTML textarea and textbox. This code works for IE 6, 7, 8, >=9, Edge, Chrome, Safari, Firefox and Opera.