Search This Blog

Wednesday, February 24, 2010

Flickr Community Guidelines


Sharing your ad space


A number of publishers have asked us if it's acceptable to place multiple publishers' ad code on the same page or site. Often they'll run into this issue when two AdSense publishers manage a site together and both want to display their ads, or if a site owner hosts content and ads from other publishers on the same page as their own.

The answer is that yes, we do allow this.

Wednesday, February 17, 2010

Preload images with jQuery


Web2.0 came with AJAX and AJAX came with its own requirements and standards for web application developers. Now web applications are more like desktop applications with a lot of options, dialogs and more. If you have developed AJAX application with different user controls you surely loaded resources such images, other javascript files on demand. This helps you keep your application lightweight and makes its load time faster.

jQuery makes creation and loading DOM elements (in our case images) very easy. If you need to preload an image you can use this jQuery script here:

// Create an image element
var image1 = $('<img />').attr('src', 'imageURL.jpg');
First jQuery creates a image DOM element and setting the src attribute of the image element would tell the user browser to load that image. Thus preloading the image.

Next you should insert your DOM element into the DOM tree using one of the many jQuery DOM manipulation methods.

Here are some examples of how you could insert preloaded image into your website:
var image1 = $('<img />').attr('src', 'imageURL.jpg');

// Insert preloaded image into the DOM tree
// OR
But the best way is to use a callback function, so it inserts the preloaded image into the application when it has completed loading. To achieve this simply use .load() jQuery event.
// Insert preloaded image after it finishes loading
('<img />')
.attr('src', 'imageURL.jpg')
('.profile').append( $(this) );
// Your other custom code