Monday 31 October 2011

CSS: terms and syntax (a tutorial for beginners)

   


How often we couldn't understand when an article explains CSS because of its terminology? Words like "element", "class", "selector" and so on, can get mixed up in our brain, and we feel like we are missing something.

Don't worry, because here I explain it all, and so there won't be any confusion anymore.

CSS stylesheets
CSS stands for Cascading Style Sheet.
I believe you already know how a stylesheet is built. Anyway, it is important to remember that a stylesheet is a set of CSS rules. It could be external (we link to the stylesheet in the head of the page), it could be embedded directly in the head of a document or it could be inline (inside the HTML element we want to style).
When we link to an external stylesheet we use the following syntax:
<head>
<link rel="stylesheet" type="text/css" href="stylesheetfilename.css" />
</head>

Friday 28 October 2011

Google Analytics: real time statistics

   


Yesterday, I have checked some statistics for The Web Thought in Google Analytics as usual, and I discovered that the Google Team introduced a new spectacular section: real time statistics.

If you go in the home section of your web site profile, you will see, just before "Intelligent Events" a new menu: "Real-Time (Beta)". It is clear that the service is still in beta version, but as far as I can see, it's incredible.

On the right side of your page, you can see the visits flowing in a real-time panel. The overview is showing the active visitors number, top referrals, top active pages, top keywords and top location.

There's then the possibility of watching live in depth reports.

In the "Locations" section you can see where your traffic is coming from, using a map or - hurray! - Google Earth.
The "Traffic Source" section is displaying the medium, source and active visitors.
The "Content" section is showing the active page and active visitors.
All the subsections have custom filters and columns ordering for tables, making statistical analysis very simple.

It's a pleasure to see the traffic coming and going in real time. It might be just a toy - at first - but I believe it could be a valuable tool to check how things are going on and eventually take immediate action when needed.

Please, let me know your experience with the tool.

Wednesday 26 October 2011

ASP: why am I still using it?

   


I have recently debated with a friend of mine about my stubborn belief in classic ASP. If you are reading The Web Thought, you already know that I mainly program in classic ASP, but you might not know why I still use it, and probably will go on using it.
Here I'll explain my ideas.

A little bit of history
First of all I would like to be clear on one thing: ASP is not a programming language, strictly speaking, but a scripting engine. VBScript is the main language used in ASP pages. In fact, my first steps into programming were made trying to understand VBA (Visual Basic for Applications). So, please be aware that in this article I will refer to ASP as a general term, not strictly to the scripting engine.

Monday 24 October 2011

ASP: how to create an excerpt from a text string

   


In the following short article, we are going to build a function which will extract an excerpt from a text string, using classic ASP. The function could be used in blogs, or in general, when we need to display just a part of an article, a news or any long text (maybe providing a link to the complete piece of text).

The function is very simple, but it has a little trick in it: it won't cut a word. Basically we are going to benefit from the InStrRev VBScript function.

Let's see the how we do it.

Friday 21 October 2011

CSS: automatic chapter numbering with counters

   


If your web page is divided in chapters fetched from a database, you can automatically number those chapters, using CSS counters. The solution is very useful in situation where the numbering is in some way dynamic.

Imagine we get chapters from our database, and list them like:
chapter 1
chapter 2
chapter 3
and so on...
What we will achieve is to automatically show them as:
1. chapter 1
2. chapter 2
3. chapter 3
Isn't it nice? Let's see how we can do it.

Wednesday 19 October 2011

ASP: conditional update or insert record

   


There are situations when we need to insert or update a record in a table according to its presence. The condition is: if the record is already in the table, then update it, otherwise insert it.

Here we will see how to do it.

Some assumptions
To achive our goal, the first task is to determine which is the condition upon which we decide to update or insert the record.
I will show you an example, that will apply to a specific situation, however, after understanding the logic, you can think of something related to your personal goal.
In the following example, we have a table (table1) with 3 columns: id, field1 and field2. We have a form submitting data. Then there's another table (table2), linked to the first table through the id field. The columns of this second table are: id and field3.
The first table (table1) might have records linked to the second table (table2), while table2 already contains records. That is a classic situation in relational databases. The point here is that we know that a unique record is present in table2, and we want to insert a new unique record in table1 if it's not already present, otherwise we need to update it.
I hope that the above explanation is clear enough.

Monday 17 October 2011

ASP: Scripting.FileSystemObject... check authorizations

   


A year ago (more or less) I wrote a series of posts about Scripting.FileSystemObject. If we use all the information gathered in those articles, we can create some sort of file explorer interface for our web site. The upload and management of files could be important, for example, in a company intranet, however, it is mandatory to follow a security policy in doing that, otherwise we end up with users messing up with files saved on our server.

Today we are going to create a simple ASP function that will check authorizations of folders. The function will try to create and delete a dummy txt file. The result of that operation will tell us if the folder has writing and reading permission or not.

Ready?

Friday 14 October 2011

CSS: resetting the browser internal stylesheet

   


As you may know, every browser has a default CSS stylesheet. Knowing that, it is possible to set all the predefined styles to neutral values. In that way, we are sure that nothing will get in the way, and that all the built-in styles (applied automatically by the browser) will be set to a baseline. The main advantage will be that every browser (no matter which one we are using) will behave in the same way, according exactly to our custom stylesheet.

In the past, there has been a long debate about resetting default stylesheets. It seems that it all started when programmers noticed a difference in predefined margins between browsers (specifically Firefox and Internet Explorer). After that, different people worked on the so called reset CSS, discussed about it and today, we can say that there are three main different opinions. Some always use reset CSS stylesheets in their projects. Others think that they are useless and that if we properly create custom stylesheets there's no need for them. Finally there are some who think that reset CSS stylesheets are only sometimes useful and they use them only when necessary.

With the contribution of people like Eric Meyer, the discussion goes on. As he says:
"The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on.
Until a few days ago, I thought it was useless. Today I might have change my mind. Here I will explain why.

Wednesday 12 October 2011

Blog Ranking (part 6) - Blog promotion

   


I've been receiving different email lately, proposing me to review softwares and web sites in exchange of something more or less valuable. While you may know that The Web Thought is not a commercial blog, what happened is a good starting point just to make a few consideration on blog ranking, or - generally speaking - about what to do to make a blog grow.

This is a post about blog promotion... be aware.

Monday 10 October 2011

Web Design: what gurus think and what I think about it

   


I've been reading a lot lately. I actually follow many blogs and sites where skilled writers share their ideas about web design and web development. Those writers usually give advices on how to think the web and specifically how to create sites with the best user experience.
The language used is a complete melting pot of technicalities, often difficult to follow, as if the writers were explaining their ideas to a very restricted circle of scholars. New terms (neologisms) are springing everywhere, sometimes creating confusion. A cryptic way of spreading new ideas, in my opinion.

Lately I've been thinking a lot about that, and I would like to humbly share my thoughts. I'm not a guru and, even though I'm a little bit experienced, I've always been outside the chorus. So here - if you are interested - I begin.

Friday 7 October 2011

JavaScript: delete default text when selecting a textarea (onblur and onfocus)

   


Today we are going to create a textarea with a simple effect. We want to obtain the following:



The text inside the textarea will disappear when the area is selected, and reappear when the area is not selected and there's no text inside it. To do so, we are going to use JavaScript.

Ready for the code? Ok, let's go.

Thursday 6 October 2011

In memory

   


(Credit: apple.com)


Wednesday 5 October 2011

jQuery & CSS: how to create a feedback slider

   


Today we are going to create a simple feedback slider using jQuery and CSS. I suppose you've seen many sliders on recently created web sites. They are used to make short forms or generic information slide over a page when a button is pressed. The slider (or tab if you prefer) can be placed where we need it and it can be styled the way we prefer.

We will create an example just to understand the basics behind it. Something like:

A form will slide down when the "feedback" button is pressed.

Monday 3 October 2011

HTML & CSS: header and footer elements for printing

   


In July this year, I've posted an article about collecting data from an xml file in order to display it and eventually print it [JavaScript: get data from an xml file (like a Blogger backup file) and display it (or print it)]. The main reason why I wrote that post is because I wanted to create a unique way of printing The Web Thought. I managed to collect the data (articles body, datestamps, titles and so on) from the xml file generated by Blogger as blog backup, so I now have a good page ready for printing.

Since then, I've worked again on the file and I've changed it a bit, just to include some specific features I needed. Basically I've changed the css style and the JavaScript code. I don't think you might be interested in that part (if you are please let me know so that I can share it), however there's a bit of code I would like to show you. Basically we want to create footers and headers for every printed page.