In: JavaScript
17 Feb 2011When making a multilingual application programmers usually find themselves in a bit of a problem when having need to translate things in JavaScript as those JavaScript files are usually separated from PHP so they can’t call translate function for this purpose. To solve this problem I have created JavaScript translate class, so please check following [...]
In: JavaScript
9 Feb 2011Sometimes you really want to refresh page when using jQuery events. So – in order to refresh page on event (in this case click) use following snippet and reload current page. 1 2 3 jQuery(’#refresh-link’).click(function() { location.reload(); });
In: JavaScript
17 Nov 2010Use jQuery visible selector to check if element is visible, and make a menu. To use jQuery visible selector and check if element is visible, just use following snippet. 1 2 3 4 5 if(jQuery(’#your-jquery-visible-id’).is(’:visible’)) { alert(’jQuery says: "It is visible!"’); } else { alert(’jQuery says: "It is not visible."’); } Now that we know [...]
In: JavaScript
15 Oct 2010In order to make JavaScript countdown I made this simple JavaScript countdown snippet you could use on your website. All you need to do is count number of seconds between current time and the moment in which something will happen. Below example is the snippet you could use. LA So, there are two parts of [...]
In: JavaScript
23 Sep 2010It could be useful to get current page URL and current page title. Especially if we want to make sharing plugin for our website. Often, we need that information in order to pass them as a parameter to sharing services like Twitter, Delicious, Facebook, etc… So, in order to get these information, you can use [...]
In: JavaScript
20 Sep 2010Present your users with Twitter followers widget by using only jQuery. Copy following snippet on your webpage, and test this amazing script, by only replacing stuntsnippets with your username. 1 2 3 4 5 6 7 8 9 10 11 12 13 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://twitter-friends-widget.googlecode.com/files/jquery.twitter-friends-1.0.min.js"></script> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery(’#friends’).twitterFriends({ debug:1,username:’stuntsnippets’,users:24,user_image:62 }); }); [...]
In: JavaScript
3 Sep 2010Not often used – jQuery hover is a function that lets you write only one function instead of two for handling mouseenter and mouseleave events. It is a useful function when you want to create drop down menus. In order to use it, you have to send two parameters to jQuery hover function. Two functions [...]
In: JavaScript
30 Aug 2010Substring is a JavaScript function which can be useful combining with jQuery. It is possible – very often that you will need limit for number of characters that user can enter in textarea in order to fill in some form. Using this simple snippet, you will be able to do so. 1 2 3 4 [...]
In: JavaScript
20 Aug 2010Prevent iframe breakout with simple onbeforeunload function. Define function on this event in order to prevent script inside of an iframe leaving it. This code asks user if he want’s to navigate away from your page. It is not the most elegant solution, but it is the one to prevent other script from iframe breakout [...]