a non-geek's blog

Random notes on linux and web development

Archive for April 2010

A simple solution for “image not available” problem

with one comment

Is there a simple solution for problems with missing or broken images? Yes, it is. You don’t need any script, just an alternate image to display when this problem occur and the “onerror” event available with the img element. Here is an example:

< img src="/path/to/image.jpg" height="100px" width="100px" onerror="this.src = '/path/to/alternate-image.png'" / >

This simple solution was posted by Satya on his web scripting blog. Anyway, if you preffer a more elegant solution, you could use a script that dynamically detects the missing images and replace them with an alternate image. A good Java Script solution is presented on the tech evangelisit’s article.

Bookmark and Share

Written by nongeekboy

April 29, 2010 at 9:31 am

Posted in HTML, JavaScript

Tagged with ,

PHP: Functions with arbitrary number of arguments

leave a comment »

Sometimes you may have to use a function with a variable number of arguments. Here is a simple method of passing a list of variables to a function:

function foo() {

// returns an array of all passed arguments
$args = func_get_args();

foreach ($args as $k => $v) {
echo "arg".($k+1).": $v\n";


/* prints nothing */

/* prints
arg1: hello

foo('hello', 'world', 'again');
/* prints
arg1: hello
arg2: world
arg3: again

For more interesting functions and futures, read the 9 useful php functions and futures you need to know article on net.tutsplus.com.

Bookmark and Share

Written by nongeekboy

April 28, 2010 at 5:43 pm

Posted in php

Tagged with , ,

DOJO: Opening menu item on mouseover when using dijit.MenuBar

with 5 comments

I’m using dojo at the project I’m working on now. One of the problems I encounter when  was how  to make the menu open when mouse over it.  I found a solution on the dojo maillist. Here is the function that does the “magic”:

dijit._MenuBase.prototype.onItemHover = function(item){


       if(this.focusedChild.popup && !this.focusedChild.disabled){

Source: here

Bookmark and Share

Written by nongeekboy

April 27, 2010 at 11:57 am

Posted in dojo

Tagged with , ,


Get every new post delivered to your Inbox.

Join 274 other followers