diff --git a/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md b/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md index 4d175ca01..6c285c1f5 100644 --- a/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md +++ b/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md @@ -1,16 +1,16 @@ -When the browser reads the `on*` attribute like `onclick`, it creates the handler from its content. +Når en browser læser `on*`-attributten som `onclick`, opretter den en håndtering ud fra dens indhold. -For `onclick="handler()"` the function will be: +For `onclick="handler()"` vil funktionen være: ```js function(event) { - handler() // the content of onclick + handler() // indholdet af onclick } ``` -Now we can see that the value returned by `handler()` is not used and does not affect the result. +Nu kan vi se, at værdien returneret af `handler()` ikke bruges og ikke påvirker resultatet. -The fix is simple: +Løsningen er enkel: ```html run -the browser will go to w3.org +browseren vil gå til w3.org ``` -The browser follows the URL on click, but we don't want it. +Browseren følger URL'en ved klik, men det er ikke det, vi vil have. -How to fix? +Hvordan løser man det? diff --git a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md index 25079cb8d..b66343476 100644 --- a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md +++ b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md @@ -1,5 +1,5 @@ -That's a great use of the event delegation pattern. +Det er en god brug af event delegation-mønsteret. -In real life instead of asking we can send a "logging" request to the server that saves the information about where the visitor left. Or we can load the content and show it right in the page (if allowable). +I virkeligheden kan vi i stedet for at spørge brugeren også sende en "logning" til en server, som gemmer informationen om hvor brugeren forlod vores site. Eller vi kan indlæse indholdet og vise det lige i siden (hvis tilladt). -All we need is to catch the `contents.onclick` and use `confirm` to ask the user. A good idea would be to use `link.getAttribute('href')` instead of `link.href` for the URL. See the solution for details. +Alt hvad vi har brug for, er at fange `contents.onclick` og bruge `confirm` til at spørge brugeren. En god idé ville være at bruge `link.getAttribute('href')` i stedet for `link.href` til URL'en. Se løsningen for detaljer. diff --git a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html index 51ac0838b..71973cd6c 100644 --- a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html +++ b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html @@ -1,40 +1,40 @@ - + +
+ + + - - - - - - - - - - - - + if (target && contents.contains(target)) { + return handleLink(target.getAttribute('href')); + } + }; + +