Pr.Pg Next Pg

HTML Interview Questions and Answers Part 5

 

41.How can I make a form with custom buttons?

  • Rather than a normal submit button (<input type="submit" ...>), you can use the image input type (<input type="image" ...>).

  • The image input type specifies a graphical submit button that functions like a server-side image map.

  • Unlike normal submit buttons (which return a name=value pair), the image input type returns the x-y coordinates of the location where the user clicked on the image.

  • The browser returns the x-y coordinates as name.x=000 and name.y=000 pairs.
    For compatability with various non-graphical browsing environments, the VALUE and ALT attributes should be set to the same value as the NAME attribute.

  • For example:
    <input type="image" name="Send" alt="Send" value="Send" src="send-button.gif">

  • For the reset button, one could use <button type="reset" ...>, JavaScript, and/or style sheets, although none of these mechanisms work universally.

 

42.How do I specify page breaks in HTML?

  • There is no way in standard HTML to specify where page breaks will occur when printing a page.

  • HTML was designed to be a device-independent structural definition language, and page breaks depend on things like the fonts and paper size that the person viewing the page is using.

 

43.How do I remove the border around frames?

  • Removing the border around frames involves both not drawing the frame borders and eliminating the space between the frames. The most widely supported way to display borderless frames is

  • <FRAMESET ... BORDER=0 FRAMEBORDER=0 FRAMESPACING=0>.
    Note that these attributes are proprietary and not part of the HTML 4.01 specifications. (HTML 4.01 does define the FRAMEBORDER attribute for the FRAME element, but not for the FRAMESET element.)

  • Also, removing the border around a frame makes it difficult to resize it, as this border is also used in most GUIs to change the size of the frame.

 

44.Why aren't my frames the exact size I specified?

  • Older versions of Netscape Navigator seems to convert pixel-based frame dimensions to whole percentages, and to use those percentage-based dimensions when laying out the frames.

  • Thus, frames with pixel-based dimensions will be rendered with a slightly different size than that specified in the frameset document.

  • The rounding error will vary depending on the exact size of the browser window.
    Furthermore, Navigator seems to store the percentage-based dimensions internally, rather than the original pixel-based dimensions.

  • Thus, when a window is resized, the frames are redrawn based on the new window size and the old percentage-based dimensions.
    There is no way to prevent this behavior.

  • To accommodate it, you should design your site to adapt to variations in the frame dimensions.

  • This is another situation where it is a good idea to accommodate variations in the browser's presentation.

 

45.How can I specify background images?

  • With HTML, you can suggest a background image with the BACKGROUND attribute of the BODY element. Here is an example:

  • <body background="imagefile.gif" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#000080">

  • If you specify a background image, you should also specify text, link, and background colors since the reader's default colors may not provide adequate contrast against your background image.

  • The background color may be used by those not using your background image. Authors should not rely on the specified background image since browsers allow their users to disable image loading or to override document-specified backgrounds.

 

46.How can I copy something from a webpage to my webpage?

  1. Plaintext or any text information viewable from your browser can be easily copied like any other text from any other file.

  2. HTML and web scripts - you will need to view the web page's source code. In the page's source code, copying the <script> and </script> tags as well as all the information in-between these tags will usually enable the script to work on your web page.

  3. Images, sounds, or movies - Almost all images, sounds, and movies can be copied to your computer and then viewed on your webpage. Images can be easily copied from a webpage by right-clicking an image and selecting "Save Picture as" or "Save Image as". Unless the sound or movies file has a direct link to download and save the file to a specified location on your hard disk drive or to view your Internet browser's cache and locate the sound or movie file saved in the cache.

  4. Embedded objects - Looking at the source code of the object to determine the name of the file and how it is loaded, and copy both the code and the file.

 

47.Is it possible to make the HTML source not viewable?

  • In short, there is no real method or script for making standard HTML source code not viewable. You may consider doing any of the below if they are concerned about your source code.

  • Create the web page in Macromedia Flash or a similar program. The visitor would need to download the Macromedia Flash plug-in and would be unable to view the source code for the flash applet.

  • There are various scripts that will disable the right click feature, preventing the user from saving images or viewing the source. However, this will not protect the source code of your page. For example, Internet Explorer users may still click "View" and "Source" to view the source code of the page, or a user could disable scripts and images can be saved by simply saving the web page to the hard drive.

  • There are several programs that will help scramble your code, making it difficult (not impossible) to read. Again, this is not going to prevent someone from viewing your code.

 

48.Why doesn't my title show up when I click "check it out"?

  • You're probably looking at the wrong part of the screen. The Title usually shows up in the Title Bar on the Window, to the left of the minimize/maximize buttons on graphical browsers.

 

49.What is the difference between the HTML form methods GET and POST?

  • The method parameter specifies which method the client is using to send information to the WEB server. The method determines which parameter you will find the CGI request data in:
    POST - post_args
    GET - httpargs

50.How do I rename all the files from .htm to .html after copying them from a PC to a UNIX machine?

  • UNIX's mv (`move') command won't handle wildcard filenames. However, there's a program called htmaddl (for `HTM-add-"L"'), so you can login and type htmaddl.

  • This will rename all .htm files to .html
    If you haven't got this program on your UNIX machine, you can type it into a file called htmaddl:
    #! /bin/sh
    for f in *.htm; do
    base=`basename $f .htm`
    mv $f $base.html
    done

  • After saving it and exiting your editor, make it executable by typing the command
    chmod ugo+x htmaddl

  • Best of all, move it into your ~/bin directory, or ask your WebMeister to put it in /usr/local/bin so everyone can use it.

Pr.Pg Next Pg