Training in Web Technologies Blog

How to include Cufon 101 font using HTML?

1. Include the JavaScript for Cufón and the Cufón font <script type=”text/javascript” src=”js/cufon-yui.js”></script> <script type=”text/javascript” src=”js/TitilliumMaps.font.js”></script> 2. HTML Normal tags <h1>Business Solutions</h1> <h2>Business Insurance</h2> 3. Tell Cufón to replace the fonts for the specified CSS selectors <script...

How to Check if Checkbox is Checked using jQuery?

Say that 10 times fast =). Find out if a single checkbox is checked or not, returns true or false: $(‘#checkBox’).attr(‘checked’); Find all checked checkboxes: $(‘input[type=checkbox]:checked’);

Why Your Business Needs to be Online?

Technology has shaped the way we do business today. Basically, everything is and can be done online. But without a website or Web presence, businesses miss huge opportunities: more business, better engagement with customers,...

Backup Database code using php

Class to back up entire databases and email them out, or individual tables. <?php class Backup { /** * @var stores the options */ var $config; /** * @var stores the final sql dump...

Embedding Quicktime using Html5

Quicktime still requires the double-object method to get it done across all browsers. Not super pretty, but it does get the job done. <object classid=”clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B” codebase=”http://www.apple.com/qtactivex/qtplugin.cab” width=”200″ height=”16″> <param name=”src” value=”movie.mov” /> <param name=”autoplay”...

Google Font API Basics using CSS3

Link to CSS files You essentially hotlink directly to CSS files on Google.com. Through URL parameters, you specificity which fonts you want, and what variations of those fonts. <head> <link rel=”stylesheet” type=”text/css” href=”http://fonts.googleapis.com/css?family=Tangerine:bold,bolditalic|Inconsolata:italic|Droid+Sans”> </head>...

how get Base64 Encode of 1x1px Transparent GIF?

Just in case you need one. You can stretch it out to fill space as needed. <img src=”data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7″> Or a black one: <img src=”data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=”>

Calculate Distance Between Mouse and Element?

(function() { var mX, mY, distance, $distance = $(‘#distance span’), $element = $(‘#element’); function calculateDistance(elem, mouseX, mouseY) { return Math.floor(Math.sqrt(Math.pow(mouseX – (elem.offset().left+(elem.width()/2)), 2) + Math.pow(mouseY – (elem.offset().top+(elem.height()/2)), 2))); } $(document).mousemove(function(e) { mX = e.pageX;...

How to add Bloginfo Shortcode?

The bloginfo() function in WordPress gives you access to lots of useful information about your site. See the complete list. To access all these values from inside Page/Post content itself, we can make a shortcode...

Browser Detection + Apply Classes to HTML Element using jQuery?

// jQBrowser v0.2: http://davecardwell.co.uk/javascript/jquery/plugins/jquery-browserdetect/ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?””:e(c/a))+String.fromCharCode(c%a+161)};while(c–){if(k[c]){p=p.replace(new RegExp(e(c),’g’),k[c])}}return p}(‘Ö ¡(){® Ø={\’¥\’:¡(){¢ £.¥},\’©\’:{\’±\’:¡(){¢ £.©.±},\’¯\’:¡(){¢ £.©.¯}},\’¬\’:¡(){¢ £.¬},\’¶\’:¡(){¢ £.¶},\’º\’:¡(){¢ £.º},\’Á\’:¡(){¢ £.Á},\’À\’:¡(){¢ £.À},\’½\’:¡(){¢ £.½},\’¾\’:¡(){¢ £.¾},\’¼\’:¡(){¢ £.¼},\’·\’:¡(){¢ £.·},\’Â\’:¡(){¢ £.Â},\’³\’:¡(){¢ £.³},\’Ä\’:¡(){¢ £.Ä},\’Ã\’:¡(){¢ £.Ã},\’Å\’:¡(){¢ £.Å},\’¸\’:¡(){¢ £.¸}};$.¥=Ø;® £={\’¥\’:\’¿\’,\’©\’:{\’±\’:²,\’¯\’:\’¿\’},\’¬\’:\’¿\’,\’¶\’:§,\’º\’:§,\’Á\’:§,\’À\’:§,\’½\’:§,\’¾\’:§,\’¼\’:§,\’·\’:§,\’Â\’:§,\’³\’:§,\’Ä\’:§,\’Ã\’:§,\’Å\’:§,\’¸\’:§};Î(® i=0,«=».ì,°=».í,¦=[{\’¤\’:\’Ý\’,\’¥\’:¡(){¢/Ù/.¨(°)}},{\’¤\’:\’Ú\’,\’¥\’:¡(){¢ Û.³!=²}},{\’¤\’:\’È\’,\’¥\’:¡(){¢/È/.¨(°)}},{\’¤\’:\’Ü\’,\’¥\’:¡(){¢/Þ/.¨(°)}},{\’ª\’:\’¶\’,\’¤\’:\’ß Ñ\’,\’¥\’:¡(){¢/à á â/.¨(«)},\’©\’:¡(){¢ «.¹(/ã(\\d+(?:\\.\\d+)+)/)}},{\’¤\’:\’Ì\’,\’¥\’:¡(){¢/Ì/.¨(«)}},{\’¤\’:\’Í\’,\’¥\’:¡(){¢/Í/.¨(°)}},{\’¤\’:\’Ï\’,\’¥\’:¡(){¢/Ï/.¨(«)}},{\’¤\’:\’Ð\’,\’¥\’:¡(){¢/Ð/.¨(«)}},{\’ª\’:\’·\’,\’¤\’:\’å...

Array of Country Names using Javascript

var country_list = [“Afghanistan”,”Albania”,”Algeria”,”Andorra”,”Angola”,”Anguilla”,”Antigua &amp; Barbuda”,”Argentina”,”Armenia”,”Aruba”,”Australia”,”Austria”,”Azerbaijan”,”Bahamas”,”Bahrain”,”Bangladesh”,”Barbados”,”Belarus”,”Belgium”,”Belize”,”Benin”,”Bermuda”,”Bhutan”,”Bolivia”,”Bosnia &amp; Herzegovina”,”Botswana”,”Brazil”,”British Virgin Islands”,”Brunei”,”Bulgaria”,”Burkina Faso”,”Burundi”,”Cambodia”,”Cameroon”,”Cape Verde”,”Cayman Islands”,”Chad”,”Chile”,”China”,”Colombia”,”Congo”,”Cook Islands”,”Costa Rica”,”Cote D Ivoire”,”Croatia”,”Cruise Ship”,”Cuba”,”Cyprus”,”Czech Republic”,”Denmark”,”Djibouti”,”Dominica”,”Dominican Republic”,”Ecuador”,”Egypt”,”El Salvador”,”Equatorial Guinea”,”Estonia”,”Ethiopia”,”Falkland Islands”,”Faroe Islands”,”Fiji”,”Finland”,”France”,”French Polynesia”,”French West Indies”,”Gabon”,”Gambia”,”Georgia”,”Germany”,”Ghana”,”Gibraltar”,”Greece”,”Greenland”,”Grenada”,”Guam”,”Guatemala”,”Guernsey”,”Guinea”,”Guinea Bissau”,”Guyana”,”Haiti”,”Honduras”,”Hong Kong”,”Hungary”,”Iceland”,”India”,”Indonesia”,”Iran”,”Iraq”,”Ireland”,”Isle of Man”,”Israel”,”Italy”,”Jamaica”,”Japan”,”Jersey”,”Jordan”,”Kazakhstan”,”Kenya”,”Kuwait”,”Kyrgyz Republic”,”Laos”,”Latvia”,”Lebanon”,”Lesotho”,”Liberia”,”Libya”,”Liechtenstein”,”Lithuania”,”Luxembourg”,”Macau”,”Macedonia”,”Madagascar”,”Malawi”,”Malaysia”,”Maldives”,”Mali”,”Malta”,”Mauritania”,”Mauritius”,”Mexico”,”Moldova”,”Monaco”,”Mongolia”,”Montenegro”,”Montserrat”,”Morocco”,”Mozambique”,”Namibia”,”Nepal”,”Netherlands”,”Netherlands Antilles”,”New Caledonia”,”New...

PHP code for Automatic Copyright Year?

Current year only &copy; <?php echo date(“Y”) ?> With start year &copy; 2008-<?php echo date(“Y”) ?> Start date with error protection <?php function auto_copyright($year = ‘auto’){ ?> <?php if(intval($year) == ‘auto’){ $year = date(‘Y’);...

How to make Basic Link Rollover as CSS Sprite?

a { display: block; background: url(sprite.png) no-repeat; height: 30px; width: 250px; } a:hover { background-position: 0 -30px; } The set height and width ensure only a portion of the sprite.png graphic is shown. The...

How do you get the footer to stay at the bottom of a Web page?

Sticky footer on Google: Have a <div> with class=”wrapper” contain everything. After the wrapper </div>, place thepush div, then the footer div. * { margin: 0; } html, body { height: 100%; } .wrapper { min-height: 100%; height: auto !important; height:...

vimeo embed showing black screen on firefox?

from vimeo api: “Note: if your site will contain a Universal Player embed, but won’t show it right away, it’s best to not to include the embed code until the video is ready to...

How to integrate WordPress template with CodeIgniter?

First step is to move CodeIgniter and the WordPress files in their own directory. After that, put the following line at the top of your CodeIgniter’s index.php file. Change the path to wp-blog-header.php as needed to...

Get WordPress Post ID from Post title

Found a solution if anyone else struggles with this. Only posted the question out of desperation after 4 hours testing/Googling! function get_post_by_title($page_title, $output = OBJECT) { global $wpdb; $post = $wpdb->get_var( $wpdb->prepare( “SELECT ID...

How to parse and process HTML/XML with PHP?

I prefer using one of the native XML extensions since they come bundled with PHP, are usually faster than all the 3rd party libs and give me all the control I need over the markup. DOM...

Can I put a html button inside the canvas?

Given that the canvas element has a transparent content model, it may contain fallback elements which are displayed in the event that the canvas element is unsupported. They will not be displayed if the canvas is supported. If you display a list of controls in...

How to show popup message using CSS and jQuery?

Here’s how  does it: This is the markup, initially hidden so we can fade it in: <div id=’message’ style=”display: none;”> <span>Hey, This is my Message.</span> <a href=”#” class=”close-notify”>X</a> </div> Here are the styles applied:...

Can scripts be inserted with innerHTML?

I tried to load some scripts into a page using innerHTML with a div. It appears that the script loads into the dom, but it is never executed (at least in ff and chrome)....

How to copy to the clipboard in JavaScript?

Automatic copying to clipboard may be dangerous, therefore most browsers (except IE) make it very difficult. Personally, I use the following simple trick: function copyToClipboard (text) { window.prompt (“Copy to clipboard: Ctrl+C, Enter”, text);...

How to Compress CSS with PHP code?

Start your CSS files with this PHP (and name it style.php): <?php ob_start (“ob_gzhandler”); header(“Content-type: text/css; charset: UTF-8”); header(“Cache-Control: must-revalidate”); $offset = 60 * 60 ; $ExpStr = “Expires: ” . gmdate(“D, d M...

How to move CMSms installation to a new server

It is a simple, four step process to move your installation from one server to another. Step 1 Clear the Cache: Login to admin, go to Site Admin/System Maintenance and clear the cache. This...