Archive for the ‘gui’ Category

Last-modified header and IE

Monday, November 20th, 2006

when you really really really don’t want 304 on dynamic pages and you are using PHP:


header(’Last-Modified: ‘.date(’r'));

this will print the date in http://www.faqs.org/rfcs/rfc2822 formatted date.

php: isUrlOffline( $url )

Wednesday, November 15th, 2006
function isUrlOffline( $url )
{
	// setup socket with timeout of 0.1 seconds
	// return -1 for error ; false for offline

	$urlpatt = '%http:\/\/([a-z-\.0-9]+)(:(\d+)){0,1}(.*)%i’;
	$am = array();
	preg_match($urlpatt, $url, $am);

	if (empty($am[1]))
	{
		return -1;
	}
	$address = gethostbyname($am[1]);
	$service_port = empty($am[3]) ? 80 : $am[3];

	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	if ($socket < 0)  return -1;

	socket_set_block($socket);
	socket_set_option(
		$socket,SOL_SOCKET, SO_SNDTIMEO
		, array("sec"=>0,"usec"=>100)
	);

	$result = socket_connect($socket, $address, $service_port);
	if ($result < 0 )   return -1;

	$in = "HEAD / HTTP/1.1\\r\\n";
	$in .= "Host: " . $am[1] . "\\r\\n";
	$in .= "Connection: Close\\r\\n\\r\\n";

	socket_write($socket, $in, strlen($in));

	$buf = "";
	while ($out = socket_read($socket, 2048))
	{
		$buf .= $out;
	}
	socket_close($socket);

	return preg_match("%HTTP/.+ 200 OK%",$buf);
}

setting css float with javascript in IE

Friday, September 29th, 2006

Just a quick reminder to self:
IE 6 (7) don’t seem to render style.float when set with javascript,
so when you want a div to float left *dont* try using:

 div.styleFloat = 'left';
 div.style['float'] = ‘left’;
 div.style.float = ‘left’;

(more…)

IE css empty div extra padding bug

Thursday, September 21st, 2006

Most webdevelopers will have been in the situation that you want to use a background-image in an empty div and there is this whitespace padding at the bottom of the image.
Your stylesheet may look like

#mtdiv {
    position:relative;
    height:8px;
    width:12px;
    background-image: url(/images/bg_small.png);
    background-repeat: no-repeat;

    /* dit i tell you i hate IE? */
    border:1px solid;
}

(more…)