Wednesday 30 March 2011

jQuery: selectors

   


If you are new to jQuery, you might be quite confused by the terms used to explain the famous library. On the other hand, if you've started to look into jQuery recently, there's one thing that is very important and that you should understand thoroughly: what are and how to use selectors.
When manipulating HTML elements in a web page, we need to be sure to select the correct element. Selectors are what you need. I know that this is the basic: without knowing what selectors are, we wouldn't be able to do almost anything with jQuery. However there are some things you might not know yet about selectors.

Monday 28 March 2011

CSS: conditional statement

   


I usually write my CSS style sheets and check them with Firefox. It is probably due to fact that I use the Web Developer toolbar to check the resulting effects. When everything is exactly the way I want it, I start checking the result with IE, Chrome and Safari. Normally, there is no problems, however some times I find glitches, especially with IE 7 or IE 6.

The golden rule
First of all, let me tell you a thing that developers think it is some sort of golden rule. Every web site must look the same with any browser. That is not true anymore. Or, let me put this way, that principle is not an absolute rule anymore. With the introduction of CSS3 and HTML 5, developers have concluded that it is not a sacrilege to have different looks with different browsers. Do not jump to strange conclusion: I am not saying that we will have completely different sites for different browsers. However, we might accept that some particular effects (generated by CSS styles) would be visible only to users with updated browsers. For example, you may already know that IE9 will be available only for Vista and Windows 7. Win XP users will stay with IE8. Those users will eventually upgrade to a newer operating system, but in the mean time, they might not enjoy CSS3 or HTML5 new features. We will have to cope with that, it is a fact.

Friday 25 March 2011

Google Analytics

   


I've been using Google Webmaster Tools for a long time, but just a few months ago I've started to have the feeling that it was not enough. What I wanted was something that could analyze my web site traffic source, visitors, search engines and so on, giving a clear idea on how my web site was performing. Thus I approached Google Analytics.

Wednesday 23 March 2011

JavaScript: special characters

   


JavaScript code is full of special characters. When coding, you will end up using a lot of apostrophes, quotes and so on. Let me explain it through a simple example.
<script type="text/javascript">
document.write("John said "Cheers!" while raising a glass of wine.");
</script>
As you may noticed, in the above code we have a series of quotes. The first one is defining the starting point of the string we want to output, while the last one is the ending point. Just to be more clear, the red quotes are the boundaries of the text string, while the green ones should be part of the string itself. If we use the above code, an error will be the result, because the first green quote will be interpreted as the ending of the string. That is as if the string is cut like:
John said
leaving the rest
Cheers!" while raising a glass of wine.
out.
How to deal with that?

Monday 21 March 2011

Blogger: a great 2011?

   


According to Blogger Buzz, 2011 will be another great year for bloggers that use Blogger - no pun intended. New features and improved usability will be released during in 2011, while 2010 has been a great year, with an incredible growth rate. The features available to bloggers have increased and blogging experience has been made significantly deeper and easier. New widgets and options have been introduced, while a completely new dashboard will be released in 2011.

The new dashboard will have a new interface that - according to Chang Kim, Product Manager of Blogger - will make things much easier to bloggers. As an example, the new post editor will be completely revised. From the posted images it is quite difficult to understand the new features, however it seems that the overall usability will be increased.

Please see the Blogger Buzz post for more information.

Friday 18 March 2011

CSS: positioning

   


Positioning of elements inside a page could be quite tricky. Nevertheless, it is a powerful way of creating wonderful layout and it gives freedom and flexibility. I would like to explain everything you need to know in order to use the correct method to place your elements using CSS styles.
First of all, let me point out that there are four method for positioning:
  1. static: this is the standard way of positioning; the element will be displayed following the normal flow of your page;
  2. fixed: a fixed positioning will place the element in a fixed position; the element won't move even if you scroll down the page;
  3. relative: with a relative positioning the element will stay relative to its normal position;
  4. absolute: the element will be positioned relative to the first parent that has a position other than static; if there's not such element, <html> will be that element.
Let's go in depth and see how they work.

Wednesday 16 March 2011

Web Sites: how to keep things tidy (with style sheets)

   


Almost three years ago, I have inherited a web site management. That web site was developed by a third party (a not-so-much-skilled web designer), using a mixture of different programming languages (JavaScript and VBScript) supported by CSS style sheets. In the past days, I've been asked to revamp the web site. Mainly, they asked for a change of colors... well, actually they wanted to obtain some sort of negative image of the web site. That means changing the black into white, and the whole grey color palette.
I am sure some of you will think that it's quite an easy task to do. And that's true... just when you (or your predecessor) have kept the things tidy!

Monday 14 March 2011

Heartquake in Japan

   


I would like again to think about Japanese people and remember all the people involved in the terrible earthquake and subsequent tsunami.
I've been in Japan for my honeymoon in 2000. I've met wonderful people there, and I've seen such astonishing places. As a tourist, I've probably seen just one side of the coin, but I can assure you, Japan is one of the places where I felt closest to nature, to real people. They are a great nation, and I hope they will find the strenght to rise again.
Thinking about the tragedy occurred last friday, my thoughts go to those who died, those who have lost everything, and those who are still suffering.
Please, say a prayer for all Japan.

JavaScript: browser detection

   


JavaScript is a great programming language and it is widely used by web developers. Personally I use JavaScript sparingly because I prefer to use VBScript whenever I can, but I must admit some times JavaScript can really simplify things a lot.
However, there is a well known issue about JavaScript. Despite the wide use and spread of JavaScript snippets, the scripts could pose compatibilities issues. For instance, some old browsers could be not completely compatible. In those cases, it is quite useful to use the navigator object in order to detect the user browser.

Friday 11 March 2011

Japan Earthquake

   


My thoughts go to people in Japan and all the affected areas by the recent earthquake and tsunami.
Stay strong!

Just wanted to say that.

Chain of Fools : Upgrading through every version of windows (HQ)

   


Today, I would like to share this great video from a guy - Andy. What's great in it? In ten (10!) minutes you can see the upgrade of every version of Microsoft Windows. What you will see is pretty amazing. Starting from MS Dos 5.00, Andy upgraded to Windows 1.01, 2.1, 3.0, Windows 95, 98, 2000 and then Windows XP, Vista and finally Windows 7.

Wednesday 9 March 2011

Browser statistics: which is the most popular browser?

   


When publishing recent post on CSS3 and HTML5, I started wondering about browser compatibility. What's the point in using state of the art technologies when - potentially - only few browsers can benefit from it?
Recently some well known blogs have published statistics about browsers popularity and so I thought I should share some thoughts about it.

Monday 7 March 2011

RSS Feeder problem

   


I just discovered I had a problem with The Web Thought RSS feeder.
Now everything's up and running.

I apologize for any inconvenience this may have caused.

CSS: Backgrounds with CSS3

   


One of the most searched effects for web sites today is the background image covering all the visible area. I've already explained a method to achieve that in the past (Making background image fit any screen resolution). With CSS3 there are a set of new property that can handle it quite easily. Let's see them.

The background-size property
The background-size property defines the size of a background image (ah!). You can set the image size in pixels or percentages. With percentage, the size will be relative to the container.
div
{
background:url(example.gif);
-moz-background-size:100% 100%; /* Firefox */
background-size:100% 100%;
background-repeat:no-repeat;
}

Friday 4 March 2011

CSS: Border radius with CSS3

   


I continue exploring new properties that will be introduced with CSS3. This time I like to share information on the border radius property, which is really a great thing, considering that most of us probably had to create such effect for a new web site or application more than once. Personally I like rounded corners, even if - I must admit - recently I've started to prefer live corners again. That is probably related to fashion or personal taste and aesthetic; however, from a technical point of view, you know how tricky is/was to create such round corners effect. At the beginning we used a set of small gif images - and that was a real mess - then came jQuery or JavaScript in general.
And what about now? CSS3!

Wednesday 2 March 2011

SQL Server: stored procedure with code fetched from database

   


I know this is crazy, but I've been thinking about it for a while. In the past I've talked about stored procedures with clauses taken from another table. Ok, I understand that this is difficult to explain. Let me try.
Let's say I have a table that contains all the company departments. I actually use this table to create parameters for a where-clause in a stored procedure. That is done because I need to change departments without having to change the stored procedure. When a new department is inserted into the departments table, the stored procedure works immediately, without the need to change it.

Said that, please follow me. Let's say I have 3 stored procedures that perform queries on different tables with appropriate joins. Part of the code of these 3 stored procedures is exactly the same. When I have to change that part of the code, I have to change it 3 times.

Would it be crazy if I put that part of the code in a table, fetch it, and use it in the stored procedure?

In my SQL Server database, I have more than 3 stored procedures in that situation. I understand that it is absolutely possible - in coding terms - to do what I said. What really worry me is: would it pose some performance issue?

I really would like if you share your thoughts on this.