JavaScript Tips & Tutorials

JavaScript: Show & Tick a Specific Local Time Clock (Fixed Time Zone) instead of Client Time

When I’m coding for a new sub site where I need to show the local time of mine and my developers’ wherever the visitors are. Things get a little bit more tricky. Time basics in JavaScript and PHP To offset time zone differences in calculation, both JavaScript and PHP specs have time stamps representing the …

JavaScript: Show & Tick a Specific Local Time Clock (Fixed Time Zone) instead of Client Time Read More »

Top 25 Most Dangerous Web Programming Errors, Loopholes and Bad Habits

As Web becomes one of the most fundamental means of communication and information delivery nowadays, and as its usage reaches population level in regards to that when the televisions prevailed, the protection of it has never been so critical. SANS institute in association with US government and various other weighty contributors, most of whom IT …

Top 25 Most Dangerous Web Programming Errors, Loopholes and Bad Habits Read More »

Which is better for AJAX requests, GET or POST?

As per HTTP protocol specifications, client browsers send http post requests in two-step processes: 1) send the headers, 2) send the data. Therefore, for websites with high volume traffic, it’s definitely preferable to choose GET method for AJAX requests over HTTP, because all it takes for GET to get out is a URL request, which …

Which is better for AJAX requests, GET or POST? Read More »

Using JavaScript to Open Excel and Word Files in HTML

One of the main reasons that you might need this is that Microsoft Excel and Word documents pervade. They are perfect media to store, display and distribute information and ideas. A rather straightforward approach is to simply link that document up. <a href=”bank/sheet.xls” >some excel file</a> Another approach is via JavaScript. <script type=”text/javascript”> function openExcel(strFilePath) …

Using JavaScript to Open Excel and Word Files in HTML Read More »

Using JavaScript to refresh and reload an iframe on main page

<iframe></iframe> is useful in many aspects. There are times when you want to refresh the content of an iframe and reload the page in it, without refreshing that of the main page, and it can be achieved with a tiny property of iframe, src. Let’s say you have an iframe of captcha that enables the …

Using JavaScript to refresh and reload an iframe on main page Read More »

Check for file size with JavaScript before uploading

File uploading is a rather common feature of interactive sites. As all servers come with a limit on the size of the file being uploaded, it would be a usability blessing for users if web developers can implement a logic to check for the file size before uploading, informing the user if the size of …

Check for file size with JavaScript before uploading Read More »

Differences of function.apply() and function.call() in JavaScript

Function object methods function.apply() and function.call() basically do the same job, that is to invoke the function as if it was the method of a specified object so that the ‘this’ keyword within the function is treated as that object rather than the global object. var x = 20; function f(s) { alert(this.x + s); …

Differences of function.apply() and function.call() in JavaScript Read More »

DOM event detection: event bubbling and event capturing

There’s essentially 2 ways for the DOM to detect any events, namely event capturing and event bubbling. Event capturing is a method that the browser captures the event from the top elements to the bottom where the event actually takes place. For example, the moment you click on an <img> which is the child of …

DOM event detection: event bubbling and event capturing Read More »

JavaScript: Changing Browser Window Width / Height

This petite JavaScript snippet defines several functions in the namespace of Geometry that will come handy when you need to manipulate window geometry, freeing you from the depressing chores of distinguishing different browsers for their distinct implementations of virtually the same features. /** * This module defines functions for querying window and document geometry. * …

JavaScript: Changing Browser Window Width / Height Read More »

Scroll to Top