If you already know how to build text-based HTML hyperlinks to a target on a different web page, you can skip this lesson.
The procedure outlined in the previous lesson for marking and linking to a specific part of the local web page, can also be used to go to a specific part of a different web page, either in your local web space, or across the internet. Let's examine both methods.
Let's close our eyes, and imagine that we want to build another web page, called "Funny Pet Stories". (OK, OK, you can't read and close your eyes at the same time, never mind that...). On our home page, we'll list the names of our pets, and on the new ("Funny Pet Stories")page, we'll have a funny story for each one.
In the "Funny Pet Stories" HTML file, we'll place our various stories, with a heading for each. Then, before each story, we'll place a uniquely-named target, just as we did in the previous lesson, using the syntax:
<A NAME="target-name"> </A>
So far, we haven't seen anything we haven't already encountered. This time, however, our links reside on a different page from our targeted text. Therefore, when we build our links, we must modify our method slightly:
<A HREF="filename#target-name"> link-description </A>
Notice that our embedded reference (between the quotation marks) now includes the filename of the page marked by the named targets. (before, when our named targets were on the same page, we just referenced the targets; the browser then assumed we were talking about the current HTML file). One thing to notice here: the filename and the target name are separated only by the '#' sign, without spaces.
If we can apply links to specific targets on a local page, we can also do it for a web page on another site altogether, by specifying the full URL. In this case, the method for building a link would be:
<A HREF="http://the.remote.url/filename#target-name"> link-description </A>
For example,lets's say you wanted to create a link on your homepage, that pointed to a specific poem "Blessing for a New Home" on the "Maddog 'n' Miracles" Poetry page. First, you would need to know the full URL and filename of the page. Usually, the browser lists this somewhere on the screen, or you can bookmark it and retrieve it from the bookmark. Using this example, we see that the full URL is 'http://www.io.com/~maddog/poems.htm'. Then, we look at the source code for the Poetry page. Most browsers have a function whereby you can "view" the source. If you don't have that, you should be able to "save" the displayed HTML file, then open it in a text editor. We need to look at the source code, because the browser doesn't normally display target names. By looking in the source code, we can recover it. In doing so, we discover that the named target for the poem we want to display ("Blessing for a New Home") is 'blessing'. Now we have all the information we need to build the link to that poem:
<A HREF="http://www.io.com/~maddog/poems.htm#blessing">click here</A> to view Carolyn's "Blessing for a Home";<BR>
click here to view Carolyn's "Blessing for a Home";<BR>
By specifying the full URL, filename, and target name, we've created a link to a page altogether different (and in a different directory / web space). Allright, allright... it so happens that the page I pointed to is still in the same web space (mine), but we've demonstrated the principle correctly nonetheless. (sheeeesh... y'all don't let me get away with anything, do ya'?)