en.javascript.info/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/task.md
Peter Roche f073dbdee9
Update task.md
'use the event delegation' -> 'use event delegation'
2019-11-25 21:02:25 -07:00

498 B

importance: 5


Catch links in the element

Make all links inside the element with id="contents" ask the user if they really want to leave. And if they don't then don't follow.

Like this:

[iframe height=100 border=1 src="solution"]

Details:

  • HTML inside the element may be loaded or regenerated dynamically at any time, so we can't find all links and put handlers on them. Use event delegation.
  • The content may have nested tags. Inside links too, like <a href=".."><i>...</i></a>.