We all know that when you hover on any link, a window appears in the browser that displays the link address. Usually, it (the window) appears in the lower left corner of the browser window. Tell me, is it possible to get the value of this link from the browser when the mouse cursor is pointed at it using javascript or by installing it in a specific container?
1 answer
Can. Proof of concept, so to speak:
<a href='https://google.com'>google</a><br> <a href='http://ya.ru'>yandex</a><br> link: <span id='href'></span> <script> var els = document.getElementsByTagName('a'); for (var i in els) { els[i].onmouseover = function() { var e = document.getElementById('href'); e.innerText = this.href; } } </script> It's on jsfiddle: http://jsfiddle.net/jokghghp/
- one
innerTextnot supported by filrefox . - romeo - Slightly corrected your example - romeo
- one@romeo Well, this is a purely demonstration of the fundamental possibility, without taking into account the features of the browsers, you could at least alert you. :) - Yaant
- @romeo - I'll see a little later how it will turn out in practice - while everything is cool. - anj1817
- @Yaant - thanks for the interesting code. - anj1817
|