Why this refer to window and not to anchor?

41 views Asked by At

Inside an HTML table a link named lnkFullScreen calls the JavaScript function fullscreenmap. Inside the function I need to change the innertext of link but link variable refer to window insted of the link.

The page include prototype.js version 1.7.1

function fullscreenmap(link) {
  $("tblMap").toggleClassName("overlay");
  if ($("tblMap").hasClassName("overlay"))
    link.innerText = "exit full screen";
  else
    link.innerText = "full screen mode";
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prototype/1.7.1.0/prototype.min.js" integrity="sha512-BfwTGy/vhB1IOMlnxjnHLDQFX9FAidk1uYzXB6JOj9adeMoKlO3Bi3rZGGOrYfCOhBMZggeXTBmmdkfscYOQ/w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<td class="thead" width="50%">
  <strong>Mappa</strong>&nbsp;-&nbsp;<a href="javascript:fullscreenmap(this)" id="linkFullScreen">full screen mode</a>
</td>

0

There are 0 answers