簡體   English   中英

在下面的javascript代碼中,“ target.href”是什么意思?

[英]what does “target.href” mean in following pice of javascript code?

代碼在這里。 aContextNav,aAddWebmark是ID名稱。

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);

在HTML中, 鏈接表示文檔和其他資源之間的連接。 使用href屬性引用該資源。

一些例子:

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

href內容屬性由href IDL屬性反映,因此在JavaScript中,您可以將其用作元素的屬性,在本例中為事件的目標。

目標的事件的是其中的元件事件分派

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM