Monday, 21 January 2013

Web Hosting Introduction



Web Hosting Introduction

How does the Internet work? How can I have my own Web Site?
What is a Web Host? What is an Internet Service Provider?

What is the World Wide Web?
  • The Web is a network of computers all over the world.
  • All the computers in the Web can communicate with each other.
  • All the computers use a communication protocol called HTTP.

How does the WWW work?
  • Web information is stored in documents called web pages
  • Web pages are files stored on computers called web servers.
  • Computers reading the web pages are called web clients.
  • Web clients view the pages with a program called a web browser.
  • Popular browsers are Internet Explorer and Firefox.

How does a Browser Fetch a Web Page?
  • A browser fetches a page from a web server by a request.
  • A request is a standard HTTP request containing a page address.
  • An address may look like this: http://www.example.com/default.htm.

How does a Browser Display a Web Page?
  • All web pages contain instructions for display.
  • The browser displays the page by reading these instructions.
  • The most common display instructions are called HTML tags.
  • HTML tags look like this This is a paragraph.
    .

What is a Web Server?
  • The collection of all your web pages is called your web site.
  • To let others view your web pages, you must publish your web site.
  • To publish your work, you must copy your site to a web server.
  • Your own PC can act as a web server if it is connected to a network.
  • Most common is to use an Internet Service Provider (ISP).

What is an Internet Service Provider?
  • ISP stands for Internet Service Provider.
  • An ISP provides Internet Services.
  • A common Internet service is web hosting.
  • Web hosting means storing your web site on a public server.
  • Web hosting normally includes email services.
  • Web hosting often includes domain name registration.

Friday, 18 January 2013

JavaScript Window History

JavaScript Window History


Window History

The window.history object can be written without the window prefix.
To protect the privacy of the users, there are limitations to how JavaScript can access this object.
Some methods:
  • history.back() - same as clicking back in the browser
  • history.forward() - same as clicking forward in the browser

Window History Back

The history.back() method loads the previous URL in the history list.
This is the same as clicking the Back button in the browser.

Example

Create a back button on a page:









The output of the code above will be:


Window History Forward

The history forward() method loads the next URL in the history list.
This is the same as clicking the Forward button in the browser.

 


Create a forward button on a page:









The output of the code above will be:


JavaScript Form Validation

JavaScript Form Validation
JavaScript can be used to validate data in HTML forms before sending off the content to a server.
Form data that typically are checked by a JavaScript could be:
  • has the user left required fields empty?
  • has the user entered a valid e-mail address?
  • has the user entered a valid date?
  • has the user entered text in a numeric field?
Required Fields

·         The function below checks if a field has been left empty. If the field is blank, an alert box alerts a message, the function returns false, and the form will not be submitted:
·         function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
  return false;
  }
}
·         The function above could be called when a form is submitted:
Example
·        

First name:



·         E-mail Validation
·         The function below checks if the content has the general syntax of an email.
·         This means that the input data must contain an @ sign and at least one dot (.). Also, the @ must not be the first character of the email address, and the last dot must be present after the @ sign, and minimum 2 characters before the end:
·         function validateForm()
{
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 atpos="atpos" dotpos="dotpos">=x.length)
  {
  alert("Not a valid e-mail address");
  return false;
  }
}
·         The function above could be called when a form is submitted:
Example
·        

Email: