You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/2-events/04-default-browser-action/article.md
+28-28Lines changed: 28 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,43 +1,43 @@
1
-
# Browser default actions
1
+
# Azioni predefinite del browser
2
2
3
-
Many events automatically lead to certain actions performed by the browser.
3
+
Molti eventi vengono ricondotti verso determinate azioni eseguite dal browser.
4
4
5
-
For instance:
5
+
Per esempio:
6
6
7
-
-A click on a link - initiates navigation to its URL.
8
-
-A click on a form submit button - initiates its submission to the server.
9
-
-Pressing a mouse button over a text and moving it - selects the text.
7
+
-Un click su un link - inizializza la navigazione verso il suo URL.
8
+
-Un click su un pulsante di invio di un form - inizializza l'invio dello stesso al server.
9
+
-Premendo e spostando il pulsante su un testo - lo seleziona.
10
10
11
-
If we handle an event in JavaScript, we may not want the corresponding browser action to happen, and want to implement another behavior instead.
11
+
Quando gestiamo un evento con JavaScript, potremmo non volere affatto che la corrispondente azione del browser avvenga, ed implementare, invece, un altro comportamento.
12
12
13
-
## Preventing browser actions
13
+
## Prevenire le azioni del browser
14
14
15
-
There are two ways to tell the browser we don't want it to act:
15
+
Ci sono due maniere per comunicare al browser che non vogliamo che esegua alcuna azione:
16
16
17
-
-The main way is to use the `event` object. There's a method`event.preventDefault()`.
18
-
-If the handler is assigned using`on<event>` (not by `addEventListener`), then returning`false`also works the same.
17
+
-La maniera principale è quella di usare l'oggetto `event`, all'interno del quale c'è il metodo`event.preventDefault()`.
18
+
-Se il gestore viene assegnato tramite`on<event>` (e non tramite `addEventListener`), allora restiruire`false`avrà lo stesso effetto.
19
19
20
-
In this HTML a click on a link doesn't lead to navigation, browser doesn't do anything:
20
+
In questo HTML un click su un link non porta a navigarlo, il browser di fatto non fa nulla:
In the next example we'll use this technique to create a JavaScript-powered menu.
28
+
Nel prossimo esempio useremo questa tecnicaper creare un menù potenziato via JavaScript.
29
29
30
-
```warn header="Returning`false`from a handler is an exception"
31
-
The value returned by an event handler is usually ignored.
30
+
```warn header="Restituire`false`da un gestore è un'eccezione"
31
+
Il valore restituito da un gestore evento solitamente viene ignorato.
32
32
33
-
The only exception is`return false`from a handler assigned using`on<event>`.
33
+
L'unica eccezione è il`return false`di un gestore assegnato con l'uso di`on<event>`.
34
34
35
-
In all other cases, `return`value is ignored. In particular, there's no sense in returning`true`.
35
+
In tutti gli altri casi, il valore del `return`viene ignorato. Nello specifico, non ha alcun senso restituire`true`.
36
36
```
37
37
38
-
### Example: the menu
38
+
### Esempio: il menù
39
39
40
-
Consider a site menu, like this:
40
+
Considera un menù di questo tipo:
41
41
42
42
```html
43
43
<ul id="menu" class="menu">
@@ -47,18 +47,18 @@ Consider a site menu, like this:
47
47
</ul>
48
48
```
49
49
50
-
Here's how it looks with some CSS:
50
+
Ecco come appare con un po' di CSS:
51
51
52
52
[iframe height=70 src="menu" link edit]
53
53
54
-
Menu items are implemented as HTML-links `<a>`, not buttons`<button>`. There are several reasons to do so, for instance:
54
+
Gli elementi del menù sono implementati com links HTML `<a>`, non pulsanti`<button>`. Ci sono tanti ragioni per fare ciò, per esempio:
55
55
56
-
-Many people like to use "right click" -- "open in a new window". If we use `<button>`or`<span>`, that doesn't work.
57
-
-Search engines follow `<a href="...">`links while indexing.
56
+
-A molte persone piace usare "tasto destro" -- "apri in una nuova finestra". Se usassimo `<button>`oppure`<span>`, questa funzionalità non potrebbe essere usata.
57
+
-I motori di ricerca seguono i link `<a href="...">`per l'indicizzazione.
58
58
59
-
So we use `<a>`in the markup. But normally we intend to handle clicks in JavaScript. So we should prevent the default browser action.
59
+
Quindi usiamo `<a>`nel markup. Ma normalmente intendiamo gestire i click tramite JavaScript e quidni dovremmo prevenire le azioni predefinite del browser.
0 commit comments