質問

Is it possible to use javascript in order when rolling over or (clicking) a word in a web page to get that word (e.g in variable). I would like to make a firefox extension with that feature.

役に立ちましたか?

解決

Ofcourse there is nothing such as clicking a word , as it is not an object , eventhough you can highlight a word , and yes you can get its value check this :

https://developer.mozilla.org/en-US/docs/Web/API/Window.getSelection

function foo() {
    var selObj = window.getSelection(); 
    alert(selObj);
    var selRange = selObj.getRangeAt(0);
    // do stuff with the range
}

他のヒント

There is a HTML attribute which can use to get a tooltip on any element.

<p><abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>

Source: http://www.w3schools.com/tags/att_global_title.asp

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top