Learn how to detect an “undefined” object property in JavaScript
Use following code to detec an undefined object property in javascript. if (typeof YOUR_VARIABLE === “undefined”) alert(“YOUR_VARIABLE is undefined”);
Continue Reading →By admin|JavaScript
Use following code to detec an undefined object property in javascript. if (typeof YOUR_VARIABLE === “undefined”) alert(“YOUR_VARIABLE is undefined”);
Continue Reading →By admin|JavaScript
The result of 1/0 is Infinity. parseInt treats its first argument as a string which means first of all Infinity.toString() is called, producing the string “Infinity”. So it works the same as if you asked it to convert “Infinity” in base 19 to decimal. Here are the digits in base 19 along with their decimal […]
Continue Reading →By admin|JavaScript
Here is the way to get timestamps in JavaScript and this will return the number of milliseconds since the epoch. new Date().getTime();
Continue Reading →By admin|JavaScript, jQuery
Here JQuery is not necessary. We can just use JavaScript to do that. And There are two methods to do that. One is window.location.href = and the other one is window.location.replace(…) window.location.replace(…) will best simulate an HTTP redirect. If you want to simulate someone clicking on a link, use location.href. If you want to simulate […]
Continue Reading →By admin|JavaScript
Here is a function to retrieve query string values via JavaScript. function getParameterByName(name) { name = name.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”); var regexS = “[\\?&]” + name + “=([^&#]*)”; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if(results == null) return “”; else return decodeURIComponent(results[1].replace(/\+/g, ” “)); }
Continue Reading →