Author Archives: Juan

Have questions or need help? Please, use the Forum

Lately, I’ve been receiving help requests (on the articles I’ve written) through this blog. For obvious reasons, I really wouldn’t like the comments area of the articles to be filled with help requests nor code so that someone can help to find out what’s ‘wrong’ with it.

The comments area of every article I’ve posted is just for, well, comments and/or contributions.

I really don’t mind people asking for help, in fact, I will be glad to lend a hand whenever I can, but please, do it in the right place: the Forum. That’s why I set it up. It makes sense, doesn’t it?

Because the forum is new and with a handful of users, chances are that I’ll be able to assist you in a prompt manner (at least, I hope so). Besides, posting on the forum can help others who may have the same questions like you.

Thank you ;) :)

J

Firefoxies.com

For some time now, I’ve been contributing to the development of Firefoxies.com and it sure has been fun!

Firefoxies.com, which is a project started by a group of students from the Standford University trying to spread Firefox, is a website where you can vote for the most “firefoxy” Firefox user. You are allowed to vote once per day per person, but you can vote for as many people as you want.

It is sorta a mash-up of people on the site. From total geeks to super models. How can it get much better.” – Firefoxies Admin

Go ahead, visit Firefoxies.com and vote for your favorite firefoxy(ies). Even better, submit your photo and have your friends vote for ya!

Cheers! ;)

CoderLab’s Forum

I’m planning to add a forum to my site. This will be done on a trial basis and will continue only if the forum is being utilized.

Like any other web development forum, its purpose will be to try to help people who can’t find an answer to a question they may have. If I know such answer, I will gladly post it on the forum.

Also, if you have a question on any of the articles that I have written on this blog, please feel free to use the forum to ask your question.

The forum will require you to register. Sorry, I know that you might only have one question and you would rather not to register but, to avoid spam, registration is required.

If you would like to collaborate and enjoy helping others, you’re more than welcome to register and start helpin’! ;).

Hopefully, the forum will be a place where we all can learn from one another.

Cheers!

———

Si gusta, usted puede leer la versión en español de este artículo.

The textContent and innerText Properties

In my original post, Using the innerText Property in Firefox, I wrote my example using document.all to determine when to use innerText or textContent.

Because the main purpose of that post was to explain to the reader that Firefox does not support the innerText property but the textContent property, I failed to consider other browsers… yes, shame on me! (thanks Paul for bringing this to my attention).

You see, there are browsers that although don’t support document.all, they DO support the innerText property: Safari and Konqueror.

So, it is more efficient to check if the innerText property is supported by the user agent (thanks, Matthias). The way I do it is like this:

var hasInnerText =
(document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
var elem = document.getElementById('id');
var elem2 = document.getElementById ('id2');

if(!hasInnerText){
    elem.textContent = value;
    elem2.textContent = value;
} else{
    elem.innerText = value;
    elem2.innerText = value;
}

Why am I using document.getElementsByTagName("body")[0]? Well, because, as you know, document.getElementsByTagName returns an array of elements with that tag name, and since there’s only ONE body tag, I’m calling the first and only index of that array at once. This is so, as you can see in the example above, if you have more than one element that you need to assign a value to.

I have an example. If you wish, check the source out to see how it works.

Compatibility:

  • Linux:
    • Konqueror 3.5.2
    • Firefox 1.5.0.1
  • Mac X:
    • Safari 2.0.3
    • Camino 1.0
  • Windows:
    • Firefox 1.5.0.2
    • Opera 8.54
    • Internet Explorer 6
    • Internet Explorer 7.0.5346.5 Beta 2

Remember, this is one way to do it. Cheers! ;)

Displaying PNG 24-bit Alpha Transparency on IE with CSS

After reading Justin Koivisto’s great article: Normal Display of PNG Alpha Transparency with MSIE and reading his PHP code, I said to myself: “myself, there should be a much simpler (lazy, if you will :D) way to accomplish this”. True, I could just copy, paste and use his code, modify the .htaccess file (or add the MIME type to the Apache server) but still… :P

Another approach is Bob Osola’s JavaScript script (this is pretty cool too) found in his article: The PNG problem in Windows Internet Explorer.

Personally, I wouldn’t use more than 2 or 3 images on a page, so I believe the use of CSS will do.

I have an example where you can see the results (please see the page source to see the code). The drawback of this approach (as it is written right now – using the background-image property) is that no image(s) will be displayed if the user has CSS disabled.

Again, if you will have lots of .png images and don’t want to have a bunch of CSS classes, you’re better off using Koivisto’s or Osola’s approach.

CSS Compatibility

  • Firefox 1.5 (Win XP and Linux)
  • Internet Explorer 6 (duh!)
  • Opera 8.51
  • Konqueror 3.5.0

I don’t have Safari but my guess is that it will work :D

Enjoy!

Hiatus

I haven’t been able to update this blog for quiet some time due to some projects I’ve been working on.

I do have a couple of articles I want to post. One of them is how to parse XML strings in Firefox and IE. This is something that took me some hours to figure out because even though there are some tutorials out there explaining how to do this, they didn’t really work for me – and probably I’m not the only one who had this ‘problem’. So, I hope someone will find it useful.

Additionally, I will be posting articles on PHP and MySQL as well… not just JavaScript and CSS stuff ;)

Finally, I would like to share with you something that my C++ teacher used to tell us:

“Remember, in programming there is always more than one way to accomplish something; the more efficient, the better”.

Happy New Year!