If you’re using jQuery the best (the only reasonable?), in my opinion, way to block an element or entire page (for example for updating it contents) is to use blockUI plugin. But, if you only have to block one or two small elements then you may consider writing your own, very simple blocker instad of using blockUI. And if you’re using jQuery only for that purpose (really small project or task), the you may try to do the same without jQuery at all.
In my humble opinion, responsive design is a future. One layout, carefully designed, will look beautiful and by user-friendly, no matter, which device user will use to view it. Of course, you can craft responsive designed website by hand, but the easiest way is to use some framework. But what about non-framework elements, like for example images? How to style them, what size should they have, to be responsive and look exactly like other, framework elements, on any device?
There are at least few approaches to solve this problem, among which one or two are not that famous.
This article shows an example, how to respond, when user of your mobile application taps on
Back button and how to exit application, after getting user confirmation, that he or she is willing to do so. It also explains, why you shouldn’t do it at all, if you plan to ship your application to multiple platforms, including Apple iOS.
Often, in many small or very small projects, you include jQuery only to have a conviniend DOM-selectors access via
$(selector) and except this, you don’t use jQuery at all. In cases like that using neither jQuery nor smaller Zepto.js isn’t pretty wise.
Here is an example on how to achieve same effect in pure JS with
They say that SPAM bots are really good these days and can figure out your e-mail out of many “traps”.
I wonder, if they can catch it out of something like this:
<a href="mailto:email@example.com" onmousedown="this.href=this.href.replace('.nononono','')" onkeydown="this.onmousedown()"> contact me</a>
I prefer to think, they don’t and that they’ll crush their ugly spammy teeth on this! :]
I was faced with a problem of picking a good photo manipulation library. Either client-side or server-side. Both for working with my newest Yii project. This article is a summary of my quick research in this field.
The only PHP image manipulation library works mostly on uploaded image.
I wanted some nice function, that will return all DOM elements:
- of given element type (name),
- contained in another element,
- having given class.
For example, to get all list items (
<li>) with some class, but inside
<ol> rather than in entire DOM tree.
I failed to find one of such, so I wrote it.
This article shows different methods on checking, if checkbox is check or set of checkboxes are set. jQuery is used. It also discussed some additional issues about this topic.
There are a lot of introduction-like posts about starting your journey with HTML5 geolocation, so I don’t intend to write another one. Instead, I’m going to say a few words about enabling and disabling in-browser geolocation services, because this topic has some glitches that may not be know by everyone.
I’ve searched the web for a Javascipt obsfucator for my specific needs — actually a minifier and obsfucator that will minify a code (pretty like BrainJar do) and obsfucate all variables, function names etc. to 1-2 character length (shortest possible). I know that this could be less secure, but due to purpose (internal project), size of the code, not security, is a key here. I also need it as one-click, on-line ready tool.
Since my searches failed, I’ve asked a question on Stack Overflow, but it was closed as off-topic.
Following article is a summary of answers already given on Stack Overflow (before question was closed) plus my some other thoughts and findings.
Ever heard about Brainfuck? It is an esoteric programming language (designed with only one purpose — to test the boundaries of computer programming… and human brain) that uses only eight single characters (
,) as entire set of programming words. Yes, it really fucks your brain!
Checking size for inline scripts is as easy as
document.getElementsByTagName('script').text.length (solution taken from here). But, when it comes to measuring size of remote resources things gets a little bit complicated. Mostly due to cross-site restrictions and reducing unnecessary server load. Head-type of AJAX call, not so famous among developers, may help in this case.
Below JS Beautifier’s main window, you’ll find more useful links to tools like above.
Here is a function that should work in virtually every browser, even really old ones. Of course, it is only useful, if you don’t use jQuery. Because, if you do, a far better way is to just call
.live() or whatever you want, and let jQuery do all the dirty work.
Some guy on Stack Overflow wanted to know how to highlight a piece of text in given page using jQuery. Finding proper solution for jQuery (client-side) took me around ten seconds as three most important search results were found on StackExchange and jQuery documentation itself. Anyway, here’s a copy of my answer.
In addition to “addClass, removeClass and hasClass without jQuery” article I wrote an example implementation of
getElementsByClassName() method to catch a collection of objects, referencing them by their class name, when you can’t or don’t want to use jQuery and it’s superb class-selectors.