Sadhon
Sadhon

Reputation: 684

what does "target.href" mean in following pice of javascript code?

Code is here. aContextNav, aAddWebmark are id names.

function $(id){
    return document.getElementById(id);
}

var target = event.target != null ? event.target : event.srcElement;
$('aContextNav').href = target.href;
$('aAddWebmark').href = 'http://luke.breuer.com/webmark/?addurl=' +
encodeURIComponent(target.href) + '&title=' + encodeURIComponent(target.innerHTML);

Upvotes: 1

Views: 444

Answers (1)

Oriol
Oriol

Reputation: 288080

In HTML, links represent a connection between the document and some other resource. That resource is referenced using the href attribute.

Some examples:

<a href="http://example.com/foo">I am a hyperlink</a>
<link rel="stylesheet" href="styles.css" />

The href content attribute is reflected by a href IDL attribute, so in JavaScript you can use it as a property of the element, in this case, the target of an event.

The target of an event is the element in which the event was dispatched.

Upvotes: 1

Related Questions