<script>
x = window.prompt('YOUR NAME')
if (x != '' && x != ' ' && x != 'null')
document.write('HAI '+x.toUpperCase())
else
document.write('HAI FRIEND')
</script>
x != '' --> x bukan kosong
x != ' ' --> x bukan spasi
x != 'null'--> x bukan null atau nol
&&--> dan
.toUpperCase()--> Huruf Kapital
if--> jika klik OK atau ENTER
else-->jika di batalkan
jika ingin mengatur fontnya dapat disisipkan kode berikut:
<script>
x = window.prompt('YOUR NAME')
if (x != '' && x != ' ' && x != 'null')
document.write('<font size="25">'+'HAI '+x.toUpperCase()+'</font>')
else
document.write('HAI FRIEND')
</script>
Sekian tips JavaScript dari saya :)
0 Response to "Window Prompt JavaScript"
Post a Comment