IE6 and IE7 both experience a problem in which images inside of block elements inside of anchors lose their click ability. Here’s an example:
<a href="rss-icon.png">
<span style="display:block; width:100px; height:100px;">
<img src="someImage.png" />
</span>
</a>
Every area of the link remains click-able except for the surface consumed by someImage.png. (Note, this problem will not show in IE8, or FF)
Here’s a very small jQuery plugin I wrote to fix this particular issue.
(function($){
$.fn.fixClick = function() {
return this.each(function(){
$(this)
.css({cursor:'pointer'})
.click(function(){
window.location.href = $(this).attr('href');
});
});
}
})(jQuery);
Simply select your target element(s) and use this plugin to make the entire anchor click-able again. Here’s an example:
$(document).ready(function(){
$('a').fixClick();
});
Here’s the first ‘tutorial’-esque video that I’ve published in my new Channel Scripting for Smarties.
Enjoy~
I just recently wrote a brand new Database class to add to my PHP library. The old one was starting to get stale. This class is capable of taking advantage of the Singleton design pattern.
<?php
/**
* @author Michael Hartmayer (michaelhartmayer[at]gmail.com)
* @copyright 2009
*/
class Db {
static $ref; // Database Resource
private $user = 'root'; // Username
private $pass = ''; // Password
private $host = 'localhost'; // Host
private $db = 'test'; // Database
private $err = array(); // Error Log
private $errHalt = true; // Toggle: Halt on DB Error?
static $q; // Last Query
static $r; // Last Results
static $singleton;
public function Db() {
return true;
}//endMethod
public function getInstance() {
if(!self::$singleton)
self::$singleton = new self;
return self::$singleton;
}//endMethod
public function setUser($i) {
$this->user = $i;
return true;
}//endMethod
public function setPass($i) {
$this->pass = $i;
return true;
}//endMethod
public function setHost($i) {
$this->host = $i;
return true;
}//endMethod
public function setDb($i) {
$this->db = $i;
return true;
}//endMethod
public function setAll($h,$u,$p,$d) {
$this->host = $h;
$this->user = $u;
$this->pass = $p;
$this->db = $d;
return;
}//endMethod
public function doConnect(){
if(!empty($this->ref))
$this->doDisconnect();
if(!$this->ref = @mysql_connect($this->host,$this->user,$this->pass))
return $this->dbErr(mysql_error());
if(!@mysql_select_db($this->db,$this->ref))
return $this->dbErr(mysql_error($this->ref));
return true;
}//endMethod
public function doDisconnect() {
if(empty($this->ref)) return false;
mysql_close($this->ref);
$this->ref = null;
return true;
}//endMethod
public function getRef() {
return($this->ref);
}//endMethod
public function dbSet($q) {
$this->q = $q;
if($this->r=@mysql_query($this->q,$this->ref))
return true;
return $this->dbErr(mysql_error($this->ref));
}//endMethod
public function dbGet($q,$type='') {
switch($type) {
case 'STR':
$resultType = MYSQL_ASSOC;
break;
case 'INT':
$resultType = MYSQL_NUM;
break;
default:
$resultType = MYSQL_BOTH;
break;
}
$this->q = $q;
if(!$this->r = mysql_query($this->q,$this->ref))
return $this->dbErr(mysql_error($this->ref));
$resultArr = array();
while($makeDbArr = mysql_fetch_array($this->r,$resultType)) {
$resultArr[] = $makeDbArr;
}//endWhile
return $resultArr;
}//endMethod
public function dbCount($table, $matchPartialQuery='') {
$this->q = "SELECT COUNT(*) AS 'COUNT' FROM `$table` $matchPartialQuery;";
if($this->r = $this->dbGet($this->q))
return $this->r[0]['COUNT'];
return $this->dbErr(mysql_error($this->err));
}//endMethod
private function dbErr($err) {
if(empty($err)) return false;
$this->err[] = $err;
if($this->errHalt==true) {
echo ">> System has halted on Db Error. <br />";
echo ">> Error Log:<br /><br />";
print_r($err);
exit;
}
return err;
}//endMethod
public function strClean($str) {
return mysql_real_escape_string($str,$this->ref);
}//endMethod
}//endClass
?>