How to Show a Title in JavaScript

How to Show a Title in JavaScript thumbnail
Display a web page title in JavaScript using the "<TITLE>" tag.

JavaScript is a popular web programming platform used for making a variety of different websites. It utilizes its own code library in addition to standard web programming codes such as HTML. Getting a title to show in JavaScript involves the use of program tags. A tag is a word or phrase lead by a "<" symbol and ended with a ">" symbol that issues a programming command. Titles can be displayed using the "<TITLE>" tag.

Instructions

    • 1

      Open the JavaScript file you would like to show a title in using a text editor.

    • 2

      Add an "<HTML>" tag to the top of the page if there isn't already one there.

    • 3

      Add a "<HEAD>" tag underneath the "<HTML>" tag. Together, the tags look like this:

      <HTML>

      <HEAD>

    • 4

      Add a "<TITLE>" tag, followed by the title you want to show and a closed "</TITLE>" tag, for example:

      <TITLE>My page title</TITLE>

    • 5

      Add the code to call up JavaScript:

      <SCRIPT LANGUAGE = JavaScript>

      alert(document.title)

      </SCRIPT>

      Steps 2 through 5 together should appear like this:

      <HTML>

      <HEAD>

      <TITLE>My page title</TITLE>

      <SCRIPT LANGUAGE = JavaScript>

      alert(document.title)

      </SCRIPT>

    • 6

      Add any other code or script you wish and save the file. The title will now be displayed.

Related Searches:

References

  • Photo Credit Jupiterimages/Photos.com/Getty Images

Comments

Related Ads

Featured