To Notes

IT 130 -- 2/24/10

Review Questions

  1. What does DNS mean?
     
    Ans: Domain Name Services or Domain Name System
     
  2. Identify the parts of this URL:

  3. Describe the steps that a browser must take to request, obtain and display a web page. Ans:
     
    1. User enters requested URL in browser.
       
    2. Browser sends request to DNS (domain name services) to get IP address of server. This could involve multiple hops, including the top-level domain server for edu, and a second-level domain server like for depaul.edu.
       
    3. Browser obtains IP address of server.
       
    4. Browser sends request for web page to IP address of server. This is an HTTP GET request.
       
    5. Server sends page back to server. The client IP address was contained in the request.
       
    6. Browser displays the web page.

     
  4. Write a JavaScript event handler that randomly displays one of the images 1.jpg, 2.jpg, or 3.jpg in the image location imgPicture. Ans:
    function display( )
    {
        var n = 1 + Math.floor(3 * Math.random( ));
        if (n == 1)
        {
            document.images.imgPicture.src = 1.jpg;
        }
        else if (n == 2)
        {
            document.images.imgPicture.src = 2.jpg;
        }
        else
        {
            document.images.imgPicture.src = 3.jpg;
        }
    }
    
    or
    
    function display( )
    {
        var n = 1 + Math.floor(3 * Math.random( ));
        document.images.imgPicture.src = n + .jpg;
    }
    

     
  5. Write a definition for imgPicture. Ans:
    <img name=imgPicture />
    

     
  6. Write a body tag that automatically calls the event handler when the page loads or is refreshed. Ans:
    <body onload=display( );>
    

     
  7. Write an external style that sets the size of imgPicture as 1.5in x 1.0in. Ans:
        img { width : 1.5in; height : 1.0in; }
    

     
  8. How do you designate a source code comment in (a) HTML, (b) CSS, (c) JavaScript? Ans:
    <!-- This is the HTML source code comment -->
    
    /* This is the CSS comment */
    
    // This is the JavaScript comment.
    

     

CSS Classes

 

Server Side Processing

 

JavaScript Examples for the Website Project

 

Practice Problems

  1. Modify the Slide Show Example to:
     
    1. Show random images. Ans: See slide-show2.htm

    2.  
    3. Show a random image when the page is loaded. The image should not change until the page is reloaded. Ans: See slide-show2.htm

 

Project 6