Spring Sale! Save $10 on The Tao of WordPress and book bundles with Digging Into WP and .htaccess made easy – Coupon code: Spring2014Get books »

Maximum and Minimum Height and Width in Internet Explorer

Behold the seventh wonder of the virtual world: max/min-height and max/min-width properties are possible in Internet Explorer! Indeed, by taking advantage of IE’s proprietary CSS attribute, expression, you too can whip IE widths and heights into desirable proportions. The CSS expression attribute enables JavaScript commands to be executed within Internet Explorer. JavaScript via CSS? Thanks, Microsoft! Why is this so great? Well, because in other, standards-compliant browsers, max/min-height and max/min-width properties are easily accomplished with this simple bit of CSS.. Read more »

Industrial-Strength Spamless Email Links

In our previous article on creating spamless email links via JavaScript, the presented method, although relatively simple to implement, is not the most effective solution available. Spambots, email harvesters, and other online scumbags relentlessly advance their scanning technology, perpetually rendering obsolete yesterday’s methods. In the case of spamless email links created client-side via JavaScript, many spambots now are able to decipher certain email addresses hidden within the JavaScript code itself. Spambots scan JavaScript for keywords such as "email" or "mail", or even character strings containing ".com" or the "@" symbol. Spambots collect and decipher such data and return the favor […] Read more »

Auto-Focus Form Elements with JavaScript

After digging through the WordPress source code, I stumbled upon this very useful JavaScript method for auto-focusing form elements upon page load. Here is the JavaScript code (place within the document head): <script type=”text/javascript”> function formfocus() { document.getElementById(‘element’).focus(); } window.onload = formfocus; </script> …and corresponding (X)HTML markup (abbreviated for clarity): <form> <input id=”element” /> <input /> <input /> </form> In this example, the first form element (identified by id=”element”) will be automatically focused when the document loads, thus facilitating the process of entering data in the form. This technique would serve users well on login pages (wink, wink;), or anywhere […] Read more »

Preloading Images with CSS and JavaScript

Fast-loading pages reduce errors, conserve bandwidth, and please visitors. One way to decrease loading times and enhance performance involves maximizing image display efficiency. Your mantra for achieving image efficiency should be "reuse, optimize, and preload.". While each of these methods plays an important role, this article will focus on methods for preloading images. Consult your server error logs to identify web pages that may require image help. Note: preloading images does not reduce bandwidth! It only decreases apparent load time, thereby enhancing user experience. Preloading via the CSS Display Property This method is a very common method for preloading images […] Read more »

One Link to Open Them All

Welcome to Perishable Press! This article explains several methods for opening multiple frames with a single link. For more excellent (X)HTML information, check out the (X)HTML tag archive. If you like what you see, I encourage you to subscribe to Perishable Press for a periodic dose of online enlightenment ;) Opening Multiple Frames with One Link Method 1: The first method of targeting multiple frames involves replacing either the entire frameset (via target="_top") or a subset of frames (via target="subset"). For example, any number of frames may be updated with a single link if that link targets a new frameset containing […] Read more »

Customize WordPress Quicktags

Note: This condensed tutorial assumes you are working with WordPress 2+ and are familiar with editing .php and/or .js files. WordPress quicktags1 provide shortcuts for adding certain bits of code to your posts. The default set of quicktags includes some handy shortcut buttons for tags such as <strong>, <a>, and <img>, as well as a few others. While the default set of quicktag buttons is occasionally useful, a quick bit of quicktag customization can easily transform your personal set of quicktag buttons into a deadly arsenal of time-saving code shortcuts. First, open the quicktags.js file, usually located in the wp-includes/js […] Read more »

Auto Clear and Restore Form Elements

Using a small bit of JavaScript, it is possible to auto-clear and restore form elements when users bring focus to them. Simply copy, paste, and modify the following code example to achieve an effect similar to this: Here is the HTML/JavaScript for your website: <input value=”Click here and this will disappear..” onfocus=”if(this.value == ‘Click here and this will disappear..’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘Click here and this will disappear..’;}” type=”text” size=”77″ /> Update [January 2nd, 2007] » Here is another auto-clear JavaScript trick that cleans up the (X)HTML code but does not auto-restore the element. […] Read more »

Optimize Convoluted Code via JavaScript

Search engines loathe crawling through convoluted lines of code. Oceans of complex JavaScript scare away the priceless indexing and archiving efforts of most major search engines, which will generally abort a crawl upon encountering such mess. The good news is that search engines actually do not deploy JavaScript, so it is possible to use JavaScript to hide those miles of messy code by using the fundamental document.write function. Place this function in an external JavaScript file, “navmenu.js”: function navMenu() { document.open(); document.write(“<div>Convoluted code goes here.</div>”); document.close(); } Link to the external JavaScript file by placing this code in the document […] Read more »

Spamless Email Address via JavaScript

Let’s face it, spam sucks. Give spammers the figurative finger by using this nifty bit of JavaScript to hide your email address from the harvesters. Here is an easy “copy-&-paste” snippet for including a spam-proof email address in your web pages. Although there are a million ways of doing this, I am posting this for the record (and because I just can’t stand deleting usable code). This technique uses JavaScript, and therefore is not 100% ideal for all users. My advice would be to include a <noscript> element that contains an image of your email address. That way, users without […] Read more »

Conditionally Load WordPress Pages

Need to load a WordPress page conditionally? For example, perhaps you need a “special” page to appear for search results? Yes? This simple PHP/JavaScript solution may be just what the doctor ordered! Simply replace “condition” with the required condition (or delete the if (condition) {} qualifier entirely), and then change the path and file names to suit your specific needs: <?php if (condition) { echo (” <script type=\”text/javascript\”> <!–//–><![CDATA[//><!-- parent.location=\"http://www.domain.com/path/to/file.html\" //--><!]]> </script> “); } else { echo (” <script type=\”text/javascript\”> <!–//–><![CDATA[//><!-- parent.location=\"http://www.domain.com/path/to/other-file.html\" //--><!]]> </script> “); } ?> Specifically, I employ the following trickery in my Killer WordPress theme: <?php endwhile; […] Read more »

sIFR Notes Plus

Here are a few sIFR Notes for Perishable Press. Just what are we looking at here? Well, first it is important to understand the sIFR variables and the order in which they should appear: (sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode) The variable, sFlashVars consists of the following sub-variables (these should be seperated with an & sign: # Align Flash text block textalign=center # Moves text any number of pixels to the right offsetLeft=3 # Moves text any number of pixels down offsetTop=3 # Adds underline links when hovered underline=true Then, inducing from the […] Read more »

Lightbox + FancyTooltips Bug Fix

For those of us enjoying the stylish functionality of Lightbox or any of its many incarnations, images "magically" overlay the window and unfold, revealing navigational buttons, image count, and of course the image titles. For those of us enjoying the stylish functionality of FancyTooltips (original link now 404 @ http://victr.lm85.com/projects/fancytooltips/) or any of its many incarnations, title and alt attributes manifest as stylish displays of CSS brilliance. However, for those of us employing both features, there is a potential JavaScript conflict. This conflict makes it impossible for Lightbox to display the contents of title attributes associated with images. Thus, if […] Read more »

Website Cluster Graphs

Ever imagine your website represented as a cluster graph? Well prepare your DOM and check out Sala’s Websites as Graphs project. Each map represents a single website page, each dot represents a different tag, and each color represents a different set of tags. Here is the graphical representation for Perishable Press (404 link removed 2014/01/29): Perishable Press DOM Graph Read more »

Lightbox Notes

To add Lightbox functionality to any single image: Add rel=”lightbox” to the anchor tag. Add a title=”” attribute to the anchor tag. Add an alt=”” attribute to the image tag. To add Lightbox functionality to any series of images: Add rel=”lightbox[value]” to the anchor tag of each image. Add a title=”” attribute to the anchor tag of each image. Add an alt=”” attribute to the image tag of each image. Any set of pictures with the same rel=”lightbox[value]” will display with nav buttons. Read more »

JavaScript Notes Plus

Welcome to Perishable Press! This article covers a plethora of useful JavaScript tips and tricks. For more excellent JavaScript information, check out the JavaScript tag archive. If you like what you see, I encourage you to subscribe to Perishable Press for a periodic dose of online enlightenment ;) Nifty JavaScript Design Tricks Clickable divs Standard design practice dictates that the site logo or banner located at the top of the page links to the home page of the site. There are several methods for including such functionality into a design, including this JavaScript trick that transforms an entire element (e.g., any […] Read more »

Latest Tweets Plug-n-play snippet to backup and restore theme options: digwp.com/2014/04/backup-resto… #wordpress