Friday, May 4, 2012

Div Height and Width Properties



Height and width style sheet properties can be tricky, but it is something that all web developers need to have a firm handle on.

You can specify the height and width using an absolute designator, cm, mm, in, pt, or pc or a relative units designator, em, ex, or px. We can override the properties, using style.



When defining the width and height of a divider, we need to understand what the size of our content is. The size of the content will dictate the size of the divider. Usually percentage or pixels will suffice for most applications.

If you don't know the size of your content, you need to fall back on percentages. The area of your screen is calculated based on the percentage you provide, in the style property.

If you are a web developer, you are well aware that static data is different than dynamic data, when defining your screen area's.



Working with static data, is allot simpler than working with dynamic data. With static data, you can easily estimate your screen size.

When working with dynamic data, often you will not know the height or width of your divider. Depending on the amount of data you are displaying.

There are two ways of dealing with this. You can either use a paging system, or define your dynamic data area's using percentages.

When defining the width take the total screen area, and divide into as many parts as you need. Height is different, you can either input an approximate value, or you can set your height to a 100 percent.

According to Cascading Style Sheets, Level 2.1 (CSS 2.1), if the height of the containing block is not explicitly set, then the element has no maximum height and the max-height property will be interpreted as zero percent. See, Cascading Style Sheets, Level 2.1 (CSS2.1).

When planning your website, make sure you estimate your screen area's correctly. A tool that may assist you in doing this is called CSSDesk.

Monday, December 19, 2011

Creating a Subdomain









Please Note: 

I have done tests on two different computers, and the results were the same. Please comment on any problems you may have. Becarful when adding comments to your directives, comma's and dots may cause issues with the directives.


 

One of the most difficult things to do when you are building a website, is to make a sub domain. A sub domain is written as, sub domain.domain.com.

You can think of it as a virtual domain. It is simply a server instruction that directs the user to a directory off of the domain you pay for, such as domain.com/example.

I just recently learned how to do this, and decided to take some time and document my findings. It wasn't easy. I must of spent half the day researching.

To create a sub domain follow these simple instructions;

1) Setup a sub directory.

2) Add a htaccess file to the root of the domain.

3) Configure the htaccess file to accept the following url, subdomain.domain.com


That's it folks. Its really that simple.

The only part that is not simple is configuring the htaccess file. Do it carefully, and it will work the first time.

The .htaccess file provides a way to make configuration changes on the server (on a per directory basis). A file that contains one or more directives is placed in the root directory, and the directives apply to that directory, and all sub directories bellow it.

If you have never used this file before, it can be quite daunting. The commands are not easy to learn, and you won't use it very much except for very specific tasks, like redirecting someone form one file to another. Its like being in command of the server, without being in total control.

Information on the .htacess file can be found at the Apache site. Search the Internet, and you will find hundreds of sites with the information you are seeking. Analysing each site is the hard part.

To start creating an htaccess file, save a file without an extension. The file name must be specified as .htaccess. The server will look for this file when someone visits your site with the modified url, subdomain.domain.com.

In the file add the following lines of code, and becareful;

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} subdomain.domain.com
RewriteCond %{REQUEST_URI} !directory/
RewriteRule ^(.*)$ http://subdomain.domain.com/directory/$1 [L]


The server will not give you any idea of what's wrong. If you make a mistake, the server will just not do anything.

with these instructions you will be off and running. Creating a sub domain is difficult if you have never done anything like it before, but doesn't have to be. Bookmark this page, and forward this to all your friends.

Sub domains lend themselves to an infinite number of possibilities. You can use them for blogs, selling space off your hosting space (until you have too many customers, and have to spend money on a dedicated or static ip), and promoting products and services, without the cost of buying and maintaining another domain. Wow!

Friday, November 18, 2011

Pass Multiple Parameters into a Javascript Function











Learn about the good parts and bad parts of javascript. When java applets failed, javascript quickly became the language of the web by default. This book digs through the good and indentions and blunders to give you a detailed look at the good parts of javascript.











It includes,

  • Syntax
  • Objects
  • Functions
  • Inheritance
  • Arrays
  • Regular expressions
  • Methods
  • Style
  • Beautiful features

It has taken me years, and I finally came across the solution to passing multiple parameters into a javascript function.

Javascript functions have a special property called arguments. They contain an array of input parameters. You can simply use the length property of the array, to find out how many parameters were passed to it.

When setting up your function, do not specify and parameters. For example I have a function called bind, that I use to call generic methods. It uses two parameters, the first parameter specifies the name of the function to be called, and the second parameter specifies the page it is used on.

The function takes no arguments, and is simple specified as bind().

In the function I setup a for loop to loop through the arguments, and determine how many parameters were passed.

for (var i = 0; i < arguments.length; i++) //Loop through total number of arguments passed into the function. { var function_name = arguments[0]; //Get first parameter. //Perform case statements here. }

When you call the function, simply specify the function call as such, bind('para1', 'para2'). That's it. It's really that easy. Then, access each parameter as an array element.

This eliminates the need to store values into hidden fields. Your functions less complicated. There are many times you need to pass more than one parameter into a javascript function. You cannot setup two parameters in the function declaration. The second parameter will always end up being null.

Bookmark this blog for future reference. It will certainly come useful.

Programming for the Web