Archive for HTML Tutorials

Javascript Basics

Javascript is a client-side scripting language which can be used to manipulate client’s browsers as well as to fetch information on a client’s machine. However, Javascript has only been used in it’s intended way recently, this is because since it’s launch back in the ’90s it has been used by spammers, hackers and virus makers to compromise client machines. The most common use of Javascript at this moment in time is for popup adverts – something which more browsers are beginning to put blocks on.

The most up to date use of Javascript has been in the creating of AJAX. AJAX is a mixture of other languages as well as Javascript which allows data to be posted back to a server without the need for pages to be reloaded. To learn more about AJAX, click here.
However good Javascript may seem to be, it has its limitations, the main one being that older browsers don’t support it.

Creating Your First Javascript

Javascript functions are located within the ‘function()’ tag. These functions can be delcared in two ways: by creating a function with its own names and variables that can be called again at any time within a script, this would be delcared in the following format: ‘function function_name(var1, var2, var3)’; functions can also be called directly which means that they can’t be used again within a script unless the code is copied since the function isn’t assigned a name, a function of this type would be declared in the following format: ‘var variable = function()’.

Any code for a function, or any part of the scipt is located within the opening and closing tags, for javascript these being ‘{‘ as the opening tag and ‘}’ as the closing tag.

Variables for a function are located in the brackets after a function name – these variables are set directly each time the function is called, and can be different each time. Variables can also be set directly within a function, but these variables can’t be different each time; these variables are set using the ‘var’ tag.

Basic Page and Browser Manipulation

The main use of javascript is to manipulate client machines and web browsers – it can also be used to manipulate web pages. Browsers can be manipulated in ways that include resizing browser windows, opening new windows with custom settings as well as creating transition effects inbetween web pages.

Opening new windows with javascript is simple as there is the built in ‘window.open’ function; the variables of this function take the following form: ‘window.open(url, windowname[, variables]). Javascript can also be used to close windows by using the ‘window.close’; to use this function you can either close another window, or you can close the window which currently open. To close another window you will need to use the function in this format: ‘windowname.close();’, to close the window which is currently open you need to the function in this format: ‘self.close();’.

Page transitions can be achieved with the use of special meta-tags within the ‘head’ section of a page. However, page transitions only work with Internet Explorer. To use page transitions youn will need to add a meta-tag named ‘Page-Enter’ if you want to use effects when someone enters the page, and a tag named ‘Page-Exit’ if you want effects to be used when someone leaves a page. The ‘Content’ part of the meta-tags needs to contain the information that will trigger the effects; to trigger them they will need to be wrapped in the ‘RevealTrans’ tag in the following format: ‘RevealTrans (Duration=Duration, Transition=TransitionNumber)’. The duration can be set in the tag, as well as the transition used; the transitions don’t go by name but by number; click here for a list of transitions and the numbers related to them.

Javascript can also be used to change a browser’s location. To do this the following code must be placed within a function which must be called within the ‘onLoad’ tag of the body tag of a web page: ‘window.location.href = ‘location’;’.

Related Posts:

  • No Related Posts

META tags and SEO

META tags are important HTML tags for providing information about the document. This is not a required tag in a web page, and therefore many developers dont put these tags in the developed web pages. But in most of the search engines these tags are used for listing and indexing the sites accurately. Google, Altavista, etc. search for the META tahs in the document to categorise that document.

Where to put META tags?
META tags should be placed in the HEAD section of an HTML page:
<html>
<head>
<meta name=”keywords” content=”keyword1,keyword2″>
<meta name=”description” content=”description is…”>
……..
</head>
<body>
……..

Major META Tags :
<META name=”doc-type” content=”web page”>
this tag indicates document type. Different types of document available are Government, Journal, Private, Public, etc.

<META name=”keywords” content=”a, list, of, keywords”>
this tag contains a list of keywords separated by comma. These are the most important keywords which indicate what information does the web page contain?

<META name=”description” content=”a description of your page”>
this tag contains descritpion about the web page and its contents. this description should short but summarised with main keywords.

<META name=”distribution” content=”global”>
Content should contain either global, local or IU (for Internal Use).

Optional META tags :
<META name=”copyright” content=”copyright statement”>
this meta tag indicates the copyright for the web page.

<META HTTP-EQUIV=”refresh” content=”0; url=index.htm”>
this tag is used widely for reloading the web page after every mentioned seconds in content. Also, here the URL represents to redirect it to index.htm .

<META name=”revisit-after” content=”7 days”>
this tag informs the bot to revisit after 7/14/21 days.

<META name=”author” content=”author’s name”>
this tag contains the name of the author of web page.

There are other meta tags like robots, revisit-after, rating, owner, publisher, etc. which can be used in a web page.

Thus, by META tags optimization web pages can achieve higher rankings in search engines. Now, most of the search engines also crawl your web page contents, so the contents of the web page should be specific and must contain the keywords for number of times. This helps the search engines to index the web pages and thus web pages gain higher rankings.

Related Posts:

  • No Related Posts

Importance of IFRAMEs

Iframes, or inline frames, allow you to load html files into an existing document. Frames are inline frames that are sometimes referred to as floating frames. One of the main advantages of the iframe tag is that it can be used to load external html or xhtml pages into the current document without distrubing the original page.

This iframe tag was not much popular when introduced because it was not supported by all the major browsers. But now Internet Explorer 4+, Netscape 6+, Firefox, Mozilla, Opera and other modern browsers all support iframes.

A basic iframe tag is :

<iframe></iframe>

However iframe supports a number of attributes like :

src, name, width, height, align, frameborder, scrolling

New html documents can be loaded into the iframe without disrupting the rest of the document. CSS and JavaScript can be used to manipulate properties of the iframe, such as its position and size. JavaScript can also be used to communicate between the document containing the iframe and the document loaded inside it.
So, dynamically the iframe contents can be replaced.

Also the iframes can be kept hidden. the hidden iframes can execute the code and then can send the results to the main document containing it using javascript. Thus, hidden iframes can be used as an alternative ti AJAX. Now-a-days many developers find it easy to use iframes for remote scripting. Remote Scripting is the process by which a client-side application running in the browser and a server-side application can exchange data without reloading the page.

Related Posts:

  • No Related Posts

Using HTML Validator

A Validator is a automated program or script to check the validity of the HTML coding of your Web pages. A validator is important tool which ensures that coding is valid as invalid code can impact the accessibility of pages and eventually the website. It is generally used before a website goes live or web pages are posted for public use to make sure that the pages can be read and used by all browsers and search engines. Some validators also check for broken links on the site i.e links which no longer work, and some also spell check your text.

Verifying the consistency and perfection of HTML elements manually is quite a tedious job and it becomes even more arduous when different sets of validation rules, such as those for cascading style sheets (CSS) and Extensible Markup Language (XML) are included in the page. By using a validation program to signalize errors in an organized manner, the HTML user can choose whether to correct code mistakes on a case-by-case basis or correct them globally by using a “find and replace” mechanism within the program.

Related Posts:

  • No Related Posts

Convert ^M to newline character in text files

If the ^M character is showing up in files while opening the file concerned, then follow these steps to convert it to a new line.
In vi use the following: 

:%s/^M/\n/g

or with perl on the command line:

$ perl -pi.bak -e ’s/^M/\n/g’

NOTE: Be sure to create the ^M by typing ctrl V followed by ctrl M.

^M is ASCII 13 (Ctrl M), which is the carriage return.

Different operating systems use different symbols to set the end of a line/new line.
Unix uses newline (\n)
Mac uses carriage return (\r)
And Windows/DOS use both (\n\r)

To prevent the ^M from showing up in files, be sure to use the ASCII (text) mode when transfering text files.

banner1

Related Posts:

  • No Related Posts
« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »