Javascript Tutorial: GoTo Function

Tutorials | Javascript Function | Javascript Array | Javascript Variables | Javascript Behaviour

School web pages need to show the current URl and the date when the page was last modified. The following JavaScript code will do this.

1. Open Notepad (or Simpletext for Mac users) and copy the following text into the body section where you want it.



It should produce something like this:
Current URL:

2. The code (location.href) will find the page address specified. If it is not specified it will find the current address.

3. document.write "writes" it onto the computer screen so that it is visible where you want it.

4. There are two variables: var m and var p

5. If you want to chage the word "updated" to "last modified" then change updated in the code, leaving the space before and after it:
var m = " updated " + document.lastModified;


6. document.LastModified is the JavaScript code that finds the date the document was last changed.




© J. K. Phillips     Disclaimer
Current URL: