|
JavaScript Displays Current URL of Each Web Page
Place this code one time on your master page and it will display as the unique full absolute URL of each individual web page within your site. It’s ideal if you’re using an html editor with master pages and you want the current URL to show up on each page, but you don’t want to have to manually do it. This might be useful as a courtesy for viewing or printing to indicate its source. There are two versions of the JavaScript: one that shows the pure
file path and one that creates a hyperlink. See also: tutorials, free tips, free information how-to books.
The following script generates the current url of the page, without the hyperlink.
<SCRIPT LANGUAGE="JavaScript"> <!-- { document.write(location.href); } // --> </SCRIPT>
It displays the current url like this:
The following script generates the current url of the page, with the hyperlink.
<SCRIPT LANGUAGE="JavaScript"> <!-- document.write('<A HREF="' + location.href +'">'); document.write(location.href); document.write('</A>'); // --> </SCRIPT>
It displays the current url like this:
We use this script ourselves at the footer of each of our web pages. The best way to verify that this is working is to try it out on one of your own web pages. Embed the code in the “body” of your page and then publish the page. If you try to verify by checking “page source,” you will be able to see the actual code in IE, but not in Netscape.
Products We Recommend.
|