Archive for February, 2007

Firefox underlining images

Wednesday, February 21st, 2007

Someone help me out before I go crazy.
Why is firefox underlining the image in this example?
Here is a screenshot (in case you’re not using firefox) - the above link looks like this in firefox:
weird underline in firefox

The code on that page is simply:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
a img {
text-decoration: none;
border: none;
}
-->
</style>
</head>
<body>
<a href="#"><img src="gecko.gif" alt="gecko" /> Test</a><br />
<a href="#"><img src="gecko.gif" alt="gecko" /></a> <a href="#">Test</a>
</body>
</html>

I thought it might be a doctype issue - but changing it doesn’t seem to make a difference.

Added after: Just to make this even more mysterious… This DOES NOT create that line:
<a href="#"><img src="gecko.gif" alt="gecko" /> </a>
It doesn’t show up until we add a *character* within the <a> tag that the underline pops up…(I’ve updated the example to show this…)

Updated 3/30/07 Shaun wins the prize for finding the solution!:a img {
display:block;
border: none;
float: left;
}

The example has been updated…

Extra space (padding) with List Items in IE

Friday, February 16th, 2007

For the past couple of days, I’ve been trying to figure out why a design I had been working on was showing extra padding (veritcally) in IE. I think I’d seen every solution such as: write the code like this:

<li>Item one</li><li>
Item two</li>

or make set them to float: left | right (which messed up the way the list was showing up…

The only thing that worked for me - was setting the line-height to the be the same size as the font-size used for the list. ie:

li {
font-size: 12px;
line-height: 12px;
}

And then you can add your own specific padding or margins as needed… Hope that saves someone the headache I just went through!!

Store Locator using PHP and AJAX

Tuesday, February 13th, 2007

Well, this was fun! I just made a store locator for a client using PHP and AJAX! :D

I was basically following the instructions from this page: SomeCoders.com (Retrieving database information with AJAX, PHP and MySQL)

Take a look…
(more…)

Force File Download

Friday, February 9th, 2007

How to force a file to download (without having to zip it up).

$filename = "secure/writeToFile.doc";

header("Content-Length: " . filesize($filename));
header('Content-Type: application/msword');
header('Content-Disposition: attachment; filename=writeToFile.doc');

readfile($filename);

a few other content types - lots more at the above link…

"pdf": "application/pdf"
"zip": "application/zip"
"xls": "application/vnd.ms-excel"
"ppt": "application/vnd.ms-powerpoint"
"gif": "image/gif"
"png": "image/png"
"jpg": "image/jpg"
"mp3": "audio/mpeg"
"mp3": "audio/mp3"
"wav": "audio/x-wav"
"mpe": "video/mpeg"
"mov": "video/quicktime"
"avi": "video/x-msvideo"

PHP if statement in shorthand

Thursday, February 8th, 2007

Another “tired of hunting for the exact syntax” things… Here’s shorthand for an “if” statement:

echo isset($var) ? $var : "sorry, nothing here";

Store all post variables/values in a session

Wednesday, February 7th, 2007

This is one of those things I use all the time but because I can’t remember things like this, I always have to look for the exact code to do it…

This will take all the values submitted in a form and store them in a session:

foreach($_POST as $k=>$v) {
$_SESSION[$k]=$v;
}

And when you’re ready to dump the session values…

session_unset();// reset session array
session_destroy(); // destroy session.

Stubborn IE list-stlye

Wednesday, February 7th, 2007

So my latest CSS fight, with which browser? IE, of course!

I was updating someone’s site, and set up a new “side menu” type navigation. I set it up as an unordered list using images for bullets, because I wanted them to change on :hover (and we know that IE will not listen to any :hover descriptions that is not an anchor (a) type). Easy enough:

.maincontent .sidemenu ul {
margin:0;
padding: 5px 0 0 0px;
list-style: none;
list-style-type:none;
}

.maincontent .sidemenu ul li {
padding: 0 0 10px 0;
margin: 0 0 0 10px;
list-style: none;
list-style-type: none;
}

.maincontent .sidemenu ul li a {
color: #000;
padding: 0 0 0 15px;
display: block;
background: url('/images/arrow-red.gif') left 4px no-repeat;
}

.maincontent .sidemenu ul li a:hover {
color: #D43D2B;
background: url('/images/arrow-black.gif') left 4px no-repeat;
}

(the padding, etc was for styling)… Looks great in Firefox, but load the page up in IE, and mysteriously, the bullet for the lists was still there…

Finally, I thought it was odd that the list-style was even stylized somewhat instead of a plain old bullet… hunted down in some of the other stylesheets of the site and noticed that there was a universal definition for UL and even though I was trying to “override” it in my stylsheet… it refused to do so in IE:

UL { list-style: circle; }

Changing that to be specific for the container it was in (which was not the sidemenu) fixed the problem…

.othercontentdiv UL { list-style: circle; }

Javascript set selection in select element

Tuesday, February 6th, 2007

I needed to set the selection of a drop down menu. As far as I can tell, if you don’t know the “index” value, then you just have to loop through to set the item as selected. If there’s an easier way to do this, please speak up in the comments. I spent WAY too long hunting for a better solution, but this was the only thing that worked:

for (var i=0; i < document.formname.dropdownboxname.length; i++) {
if (document.formname.dropdownboxname[i].value == “value”) {
document.formname.dropdownboxname[i].selected = true;
}
}

Firefox???

Monday, February 5th, 2007

Is it just me or with the last update to Firefox has it been… uhm.. particularly buggy? I’ve had it crashed more than ever before, and it’s just… slow… I used to LOVE firefox. But this is getting pretty annoying. I don’t have an outrageous number of addons/extensions running, but I might try turning them off (then back on one at a time) to see if that helps… Anyone else having issues? (I’m using ver 2.0.0.1)