File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
2-ui/2-events/04-default-browser-action/1-why-return-false-fails Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1- When the browser reads the ` on* ` attribute like ` onclick ` , it creates the handler from its content .
1+ Pada saat _ browser _ membaca atribut ` on* ` seperti ` onclick ` , _ browser _ akan membuat sebuah penangan ( _ handler _ ) dari kontennya .
22
3- For ` onclick= "handler()" ` the function will be :
3+ Untuk ` onclick"handler()" ` fungsinya akan menjadi :
44
55``` js
66function (event ) {
7- handler () // the content of onclick
7+ handler () // konten dari onclick
88}
99```
1010
11- Now we can see that the value returned by ` handler() ` is not used and does not affect the result .
11+ Sekarang kita bisa melihat bahwa nilai yang dikembalikan oleh ` handler() ` tidak digunakan dan tidak mempengaruhi hasilnya .
1212
13- The fix is simple :
13+ Cara memperbaikinnya mudah :
1414
1515``` html run
1616<script >
@@ -23,7 +23,7 @@ The fix is simple:
2323<a href =" https://w3.org" onclick =" *!*return handler()*/!*" >w3.org</a >
2424```
2525
26- Also we can use ` event.preventDefault() ` , like this :
26+ Kita juga bisa menggunakan ` event.preventDefault() ` , seperti ini :
2727
2828``` html run
2929<script >
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ importance: 3
22
33---
44
5- # Why "return false" doesn't work ?
5+ # Mengapa "return false" tidak berfungsi ?
66
7- Why in the code below ` return false ` doesn't work at all ?
7+ Kenapa pada kode dibawah ` return false ` tidak berfungsi sama sekali ?
88
99``` html autorun run
1010<script >
@@ -14,9 +14,9 @@ Why in the code below `return false` doesn't work at all?
1414 }
1515 </script >
1616
17- <a href =" https://w3.org" onclick =" handler()" >the browser will go to w3.org</a >
17+ <a href =" https://w3.org" onclick =" handler()" >browser akan membuka w3.org</a >
1818```
1919
20- The browser follows the URL on click, but we don't want it .
20+ _ browser _ akan mengikuti URL yang di klik, tapi kita tidak mau hal itu terjadi .
2121
22- How to fix ?
22+ Bagaimana cara memperbaikinya ?
You can’t perform that action at this time.
0 commit comments