Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




Previous Table of Contents Next

target

The target property initially reflects the TARGET property of the <A HREF="…"> or <AREA HREF="…"> HTML definitions. Setting the value of this property overrides the initial definition.

The target property (document.links[index].target) cannot be assigned a JavaScript expression or variable.

Referring Documents

When a user clicks a link in one document and causes a new page to load in the same or other window, the calling document is known as the referring document. When a user arrives at a page via a link from another page (and not from his or her bookmark, history list, friends, etc.), the URL of the referring page is reflected in the new page as a read-only property, document.referrer. You should also know that a referring document is also called the source document, whereas the new page the referrer document links to is known as the destination document.

The property document.referred is very useful for tracking a user’s movement inside a large site you maintain by yourself. It is not helpful at all if the user surfs to foreign pages, so, unless Playboy provides a link to your page, you won’t be able to greet the user with a message such as “Naughty boy—Playboy is for grown-ups only!”

Suppose you have a page on your site, C.html, that is linked from two different pages, A.html and B.html. Let’s say A.html includes important copyright information on a shareware product available on C.html, and B.html provides important instructions on installing the software package. You can use the following JavaScript script on C.html to check where the user came from and to print a link to the third page:

<SCRIPT LANGUAGE="JavaScript">
<!-- begin JavaScript *immediate* script

// assign greater than character without literally displaying it
var gt = unescape("%3E")

if (document.referred.indexOf("A.html") == –1)
document.write('<A HREF="A.html"'+gt+'Copyright notice</A'+gt)
if (document.referred.indexOf("B.html") == –1)
document.write('<A HREF="B.html"' + gt + 'Installation
instructions</A' + gt)
// -->
</SCRIPT>

This script prints links to the documents the user has not come from. It prints A.html it the user has not come from A.html, B.html if the user has not come from B.html, or both links if the user has apparently arrived from a different document or not from a link at all.

Summary

In this chapter, we discussed the Link, Area, and Anchor objects. You learned that the only way to reference one of these objects is by either document.links or document.anchors. There are three important concepts you should remember from this chapter:

  • The javascript: protocol specifies a JavaScript statement for the HREF attribute of a link or image map area.
  • The onMouseOver event handler of links and image map areas can execute a JavaScript statement. When the user places the mouse pointer over the link, it is an indication for his or her interest in it, so displaying related information in the status bar may be very helpful in such a scenario.
  • The onMouseOut event handler is also an attribute of a link or image map area. Its usage is similar to that of onMouseOver event handler.
Previous Table of Contents Next


With any suggestions or questions please feel free to contact us